QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#128513#4996. Icy ItinerarylikeblgWA 9ms53792kbC++14741b2023-07-21 08:03:162023-07-21 08:03:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-21 08:03:19]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:53792kb
  • [2023-07-21 08:03:16]
  • 提交

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{
					pa2[++cnt2]=pa1[cnt1];
					pa2[++cnt2]=i;
					cnt1--;
				}
			}
		}
	}
	for(int i=1;i<=cnt1;i++)cout<<pa1[i]<<" ";
	for(int i=1;i<=cnt2;i++)cout<<pa2[i]<<" ";
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 53792kb

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: 6ms
memory: 51368kb

input:

5 0

output:

1 2 3 4 5 

result:

ok qwq

Test #3:

score: -100
Wrong Answer
time: 9ms
memory: 51616kb

input:

10 10
7 8
7 5
5 2
6 1
10 7
4 6
5 8
3 2
10 5
1 10

output:

2 1 3 4 5 6 7 0 8 9 10 

result:

wrong answer Integer 0 violates the range [1, 10]