QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310337#4996. Icy Itinerary11d10xyWA 1ms3720kbC++14574b2024-01-21 11:24:252024-01-21 11:24:26

Judging History

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

  • [2024-01-21 11:24:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-01-21 11:24:25]
  • 提交

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