QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310337 | #4996. Icy Itinerary | 11d10xy | WA | 1ms | 3720kb | C++14 | 574b | 2024-01-21 11:24:25 | 2024-01-21 11:24:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
set<pair<int,int>>e;
list<int>ans{1,2};
int main(){
cin>>n>>m;
for(int u,v;m--;)scanf("%d%d",&u,&v),e.emplace(u,v),e.emplace(v,u);
auto it=begin(ans);
for(int i=3;i<=n;i++)if(it==begin(ans)){
ans.insert(it,i);
if(e.count({*it,*next(it)})==e.count({i,*it}))it--;
}else{
int x=e.count({*prev(it),*it}),y=e.count({*it,i}),z=e.count({*it,*next(it)});
if(x==y)it=ans.insert(next(it),i);
else it=ans.insert(it,i);
}for(int x:ans)printf("%d ",x);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3720kb
input:
4 4 1 2 1 3 1 4 3 4
output:
4 3 1 2
result:
wrong answer The first number wasn't 1