QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396620#4996. Icy ItineraryNetwork_ErrorWA 0ms5700kbC++14948b2024-04-22 22:26:442024-04-22 22:26:45

Judging History

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

  • [2024-04-22 22:26:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5700kb
  • [2024-04-22 22:26:44]
  • 提交

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: 100
Accepted
time: 0ms
memory: 5680kb

input:

4 4
1 2
1 3
1 4
3 4

output:

1 3 4 2 

result:

ok qwq

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 5700kb

input:

5 0

output:

1 2 

result:

wrong output format Unexpected end of file - int32 expected