QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75345#4996. Icy ItineraryWJLWA 0ms14816kbC++141.0kb2023-02-04 21:28:502023-02-04 21:28:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 21:28:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:14816kb
  • [2023-02-04 21:28:50]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+3;
int n,m,pre[N],nex[N],fen,vis[N],vis2[N];
vector<int>vec[N];
int main(){
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	if(!vec[1].size())nex[1]=2,pre[2]=1,fen=1,vis2[1]=1,vis2[2]=1;
	else pre[vec[1][0]]=1,nex[1]=vec[1][0],fen=vec[1][0],vis2[1]=1,vis2[vec[1][0]]=1;
	for(int i=1;i<=n;i++){
		if(vis2[i])continue;
		for(int j=0;j<(int)vec[i].size();j++){
			vis[vec[i][j]]=i;
		}
		if(vis[fen]==i){
			if(nex[fen]!=0)pre[nex[fen]]=i;
			nex[i]=nex[fen];
			nex[fen]=i;
			pre[i]=fen;
			if(vis[nex[i]]==i)fen=nex[i];
			else fen=i;
		}
		else{
			if(fen==1){
				pre[nex[1]]=i;
				nex[i]=nex[1];
				pre[i]=1;
				nex[1]=i;
			}
			else{
				nex[pre[fen]]=i;
				pre[i]=pre[fen];
				pre[fen]=i;
				nex[i]=fen;
				if(vis[pre[i]]==i)fen=i;
				else fen=pre[i];
			}
		}
	}
	int x=1;
	while(x!=0){
		printf("%d ",x);
		x=nex[x];
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 14816kb

input:

4 4
1 2
1 3
1 4
3 4

output:

1 3 4 2 

result:

ok qwq

Test #2:

score: 0
Accepted
time: 0ms
memory: 14424kb

input:

5 0

output:

1 5 4 3 2 

result:

ok qwq

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 13876kb

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 10 9 8 7 5 4 3 2 6 

result:

wrong answer Changed color too many times (5)