QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#396620 | #4996. Icy Itinerary | Network_Error | WA | 0ms | 5700kb | C++14 | 948b | 2024-04-22 22:26:44 | 2024-04-22 22:26:45 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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