QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396617#4996. Icy ItineraryNetwork_ErrorWA 1ms5780kbC++14946b2024-04-22 22:23:272024-04-22 22:23:27

Judging History

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

  • [2024-04-22 22:23:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5780kb
  • [2024-04-22 22:23:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define int long long
int n,m,L[300010],R[300010];
map<int,map<int,bool> > p;
void work(){
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)cin>>u>>v,p[u][v]=p[v][u]=1;
	int s=1;
	for(int i=2,mid=1;i<=n;i++){
		if(!R[mid])L[R[mid]=i]=mid;
		else if(!L[mid])R[L[mid]=i]=mid,s=i;
		else{
//			deb(i);
			if(p[mid][i]){
				int nxt=R[mid];
				L[R[mid]=i]=mid;
				R[L[nxt]=i]=nxt;
				mid=p[i][nxt]?nxt:i;
			}else{
				int nxt=L[mid];
				L[R[nxt]=i]=nxt;
				R[L[mid]=i]=mid;
				mid=p[nxt][i]?i:nxt;
			}
		} 
	}
	for(int i=s;i;i=R[i])cout<<i<<' ';cout<<'\n';
}
signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5780kb

input:

4 4
1 2
1 3
1 4
3 4

output:

3 1 4 2 

result:

wrong answer The first number wasn't 1