QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310845#4996. Icy Itinerarysumi007WA 4ms17756kbC++141.6kb2024-01-21 18:54:222024-01-21 18:54:22

Judging History

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

  • [2024-01-21 18:54:22]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:17756kb
  • [2024-01-21 18:54:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ldb long double
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define lowbit(i) i&(-i)
const int N = 3e5+5;
int n,m;
map<int,int> g[N];
vector<int> vec[2],ans; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int u,v;
		cin >> u >> v;
		g[u][v] = g[v][u] = 1;
	} 
	vec[0].pb(1);
	for(int i=2;i<=n;i++){
		if(!vec[0].size()){
			vec[0].pb(i);
			continue;
		}
		if(!vec[1].size()){
			vec[1].pb(i);
			continue;
		}
		int t1 = vec[0].back(),t2 = vec[1].back();
		if(g[i][t1]){
			vec[0].pb(i);
		}else if(!g[i][t2]){
			vec[1].pb(i);
		}else{
			if(g[t1][t2]){
				vec[1].pop_back();
				vec[0].pb(t2),vec[0].pb(i);
			}else{
				vec[0].pop_back();
				vec[1].pb(t1),vec[0].pb(i);
			}
		}
	}
	for(int i:vec[0]) ans.pb(i);
	for(int i:vec[1]) ans.pb(i);
	if(vec[0].size()==0 || vec[0][0]!=1){
		ans.clear();
		vec[0].clear();
		vec[1].clear();
		vec[1].pb(1);
		for(int i=2;i<=n;i++){
			if(!vec[0].size()){
				vec[0].pb(i);
				continue;
			}
			if(!vec[1].size()){
				vec[1].pb(i);
				continue;
			}
			int t1 = vec[0].back(),t2 = vec[1].back();
			if(g[i][t1]){
				vec[0].pb(i);
			}else if(!g[i][t2]){
				vec[1].pb(i);
			}else{
				if(g[t1][t2]){
					vec[1].pop_back();
					vec[0].pb(t2),vec[0].pb(i);
				}else{
					vec[0].pop_back();
					vec[1].pb(t1),vec[0].pb(i);
				}
			}
		}
		for(int i:vec[1]) ans.pb(i);
		for(int i:vec[0]) ans.pb(i);
	}
	for(int x:ans) cout << x <<" ";
	return 0;
}


詳細信息

Test #1:

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

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: 4ms
memory: 17756kb

input:

5 0

output:

1 2 3 4 5 

result:

ok qwq

Test #3:

score: 0
Accepted
time: 2ms
memory: 17668kb

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

result:

ok qwq

Test #4:

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

input:

2 1
1 2

output:

1 2 

result:

ok qwq

Test #5:

score: 0
Accepted
time: 4ms
memory: 17696kb

input:

2 0

output:

1 2 

result:

ok qwq

Test #6:

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

input:

3 1
1 3

output:

1 3 2 

result:

ok qwq

Test #7:

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

input:

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

output:

1 3 4 5 2 6 8 9 10 7 

result:

ok qwq

Test #8:

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

input:

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

output:

1 3 4 5 6 7 8 9 10 2 

result:

ok qwq

Test #9:

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

input:

15 40
12 11
11 6
5 11
15 14
10 14
15 5
1 11
10 12
4 3
6 4
4 9
2 11
6 12
13 7
7 9
10 9
1 2
9 11
2 6
7 14
2 9
3 13
9 1
2 7
8 11
1 10
13 1
4 15
3 7
2 15
6 5
10 15
4 14
15 6
2 4
3 11
1 14
2 8
1 8
10 7

output:

1 3 5 7 8 9 6 10 13 14 12 2 4 11 15 

result:

wrong answer Changed color too many times (2)