QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310339#4996. Icy Itinerary11d10xyWA 0ms4108kbC++14588b2024-01-21 11:25:352024-01-21 11:25:35

Judging History

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

  • [2024-01-21 11:25:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4108kb
  • [2024-01-21 11:25:35]
  • 提交

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)