QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310339 | #4996. Icy Itinerary | 11d10xy | WA | 0ms | 4108kb | C++14 | 588b | 2024-01-21 11:25:35 | 2024-01-21 11:25:35 |
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=prev(end(ans));
for(int i=3;i<=n;i++)if(next(it)==end(ans)){
ans.insert(end(ans),i);
if(e.count({*it,*prev(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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4108kb
input:
4 4 1 2 1 3 1 4 3 4
output:
1 4 2 3
result:
ok qwq
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3788kb
input:
10 10 7 8 7 5 5 2 6 1 10 7 4 6 5 8 3 2 10 5 1 10
output:
1 2 4 5 6 8 9 10 7 3
result:
wrong answer Changed color too many times (2)