QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128517 | #4996. Icy Itinerary | likeblg | WA | 6ms | 54160kb | C++14 | 810b | 2023-07-21 08:15:34 | 2023-07-21 08:15:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int const N=1e6+10;
map<int,int>G[N];
int pa1[N],pa2[N],n,m,cnt1,cnt2;
int main(){
cin>>n>>m;
if(m==0){
for(int i=1;i<=n;i++)cout<<i<<" ";
return 0;
}
for(int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
G[x][y]=1;
G[y][x]=1;
}
pa1[1]=1;cnt1=1;
for(int i=2;i<=n;i++){
if(G[i][pa1[cnt1]])pa1[++cnt1]=i;
else{
if(!G[i][pa2[cnt2]])pa2[++cnt2]=i;
else{
if(G[pa1[cnt1]][pa2[cnt2]]){
pa1[++cnt1]=pa2[cnt2];
pa1[++cnt1]=i;
cnt2--;
}
else{
if(cnt1){
pa2[++cnt2]=pa1[cnt1];
pa2[++cnt2]=i;
cnt1--;
}
else{
pa1[++cnt1]=i;
}
}
}
}
}
for(int i=1;i<=cnt1;i++)cout<<pa1[i]<<" ";
for(int i=1;i<=cnt2;i++)cout<<pa2[i]<<" ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 54160kb
input:
4 4 1 2 1 3 1 4 3 4
output:
1 3 2 4
result:
ok qwq
Test #2:
score: 0
Accepted
time: 4ms
memory: 51272kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 53456kb
input:
10 10 7 8 7 5 5 2 6 1 10 7 4 6 5 8 3 2 10 5 1 10
output:
8 2 1 3 4 5 6 7 9 10
result:
wrong answer The first number wasn't 1