QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277592#7883. Takeout Delivering1677118046#Compile Error//C++171.5kb2023-12-06 20:29:372023-12-06 20:29:37

Judging History

你现在查看的是最新测评结果

  • [2023-12-06 20:29:37]
  • 评测
  • [2023-12-06 20:29:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nn=3e5+10;
vector<pair<ll,ll>>XX[nn];
ll dis[nn][2];//维护最大值和次大值 1最大0次大 
ll vis[nn];//判断是否更新 
int vis2[nn];//判断是否在栈里 
ll n,m;
void bfs(int x){
	deque<int>X;
	X.push_back(x);
	memset(dis,0x3f,sizeof dis);
	dis[x][0]=0;dis[x][1]=0;
	while(!X.empty()){
		int id=X.front();
		X.pop_front();
		if(vis[id])continue;
		vis[id]++;
		vis2[ne]--;
		for(auto ii:XX[id]){
			int ne=ii.first;
			ll val=ii.second;
			ll an1=dis[ne][0]+dis[ne][1];
			if(val>dis[id][1]){
				if(an1>val+dis[id][1]){
					dis[ne][0]=dis[id][1];
					dis[ne][1]=val;
					if(vis2[ne])continue;
					vis2[ne]++;
					if(vis[ne])vis[ne]=0;
					X.push_back(ne);
				}
			}else if(val>dis[id][0]){
				if(an1>dis[id][1]+val){
					dis[ne][1]=dis[id][1];
					dis[ne][0]=val;
					if(vis2[ne])continue;
					vis2[ne]++;
					if(vis[ne])vis[ne]=0;
					X.push_back(ne);
				}
			}else{
				if(an1>dis[id][1]+dis[id][0]){
					dis[ne][1]=dis[id][1];
					dis[ne][0]=dis[id][0];
					if(vis2[ne])continue;
					vis2[ne]++;
					if(vis[ne])vis[ne]=0;
					X.push_back(ne);
				}
			}
		}
	}
}
void solve(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;ll w;
		cin>>u>>v>>w;
		XX[u].push_back({v,w});
		XX[v].push_back({u,w});
	}
	bfs(1);
	cout<<dis[n][1]+dis[n][0]<<"\n";
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	solve();
}

Details

answer.code: In function ‘void bfs(int)’:
answer.code:20:22: error: ‘ne’ was not declared in this scope; did you mean ‘nn’?
   20 |                 vis2[ne]--;
      |                      ^~
      |                      nn