auto的编译错误?
查看原帖
auto的编译错误?
549521
boy♂Next♂dooor楼主2023/11/28 21:51

用 devc++ 5.11 运行auto哪里会报错 网上查过了 也试过在编译器选项加-std=c++11 改成iso C++11 还有把程序的g++那里改成g++ -std=c++11 最后还是不行 有谁知道怎么搞的吗TAT

#include<bits/stdc++.h>
#define N 20001
#define inf 0x3f3f
using namespace std;
struct node{
	int u,i,dis;
	bool operator < (const node t) const
	{
		return dis > t.dis;
	}
};
vector<pair<int, int> > g[N];
priority_queue<node> q;
int d[N][101];//d[u][i]即到u点时间模k为i时的最短时间 
bool flag[N][101];//标记是否在此状态下参观过 
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	while(m--)
	{
		int u,v,a;
		cin>>u>>v>>a;
		g[u].push_back({v,a});
	}
	memset(d,inf,sizeof(d));
	d[1][0]=0;//在1时时间为0也是最短时间 
	q.push({1,0,d[1][0]});
	while(q.size())
	{
		int u=q.top().u;//当前的位置 
		int i=q.top().i;//当前的时间状态 
		q.pop();
		if(flag[u][i]) continue;//已走过 则跳过
		flag[u][i]=1; 
		int t=d[u][i];//当前时刻 
		for (auto [v, a] : g[u]) //遍历连着u的点v和v的开放时间a 
		{
			int j=(i+1)%k;
			if(t<a) t+=(a-t+k-1)%k*k;//时间未到 等这么个k s.t.刚好过开放时间 -1是因为如果刚好开发就不用向上取整了
			if(d[v][j]>t+1) 
			{
				d[v][j]=t+1;
				q.push((node){v,j,d[v][j]});
			}
		}
	}	
	
	if(d[n][0]<inf) cout<<d[n][0];
	else if(d[n][0]==inf)cout<<-1;
	return 0;	
}



2023/11/28 21:51
加载中...