QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592797 | #4996. Icy Itinerary | ship2077 | WA | 25ms | 57700kb | C++23 | 1.3kb | 2024-09-27 07:57:49 | 2024-09-27 07:57:50 |
Judging History
answer
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
constexpr int M=3e5+5;
cc_hash_table<int,int>mp[M];
int n,m;vector<int>ans1,ans2;
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
int check(int x,int y){return mp[x].find(y)!=mp[x].end();}
int main(){
n=read();m=read();
for (int i=1;i<=m;i++){
int x=read(),y=read();
mp[x][y]=mp[y][x]=1;
}
ans1={2};
for (int i=3;i<=n;i++){
int p=check(1,ans1[0]);
if (p==check(ans1.back(),i)){
ans1.emplace_back(i);
if (!ans2.empty()&&p==check(i,ans2.back()))
ans1.emplace_back(ans2.back()),ans2.pop_back();
}
else {
ans2.emplace_back(ans1.back());ans1.pop_back();
ans2.emplace_back(i);
if (ans1.size()&&p!=check(ans1.back(),ans2.back()))
ans1.emplace_back(ans2.back()),ans2.pop_back();
ans1.emplace_back(ans2.back());ans2.pop_back();
}
}
printf("1 ");
for (auto x:ans1) printf("%d ",x);
reverse(ans2.begin(),ans2.end());
for (auto x:ans2) printf("%d ",x);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 19ms
memory: 57688kb
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: 17ms
memory: 57680kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: 0
Accepted
time: 11ms
memory: 57624kb
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 3 4 5 6 2 8 9 10 7
result:
ok qwq
Test #4:
score: 0
Accepted
time: 17ms
memory: 57684kb
input:
2 1 1 2
output:
1 2
result:
ok qwq
Test #5:
score: 0
Accepted
time: 22ms
memory: 57552kb
input:
2 0
output:
1 2
result:
ok qwq
Test #6:
score: 0
Accepted
time: 14ms
memory: 57596kb
input:
3 1 1 3
output:
1 2 3
result:
ok qwq
Test #7:
score: 0
Accepted
time: 22ms
memory: 57696kb
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 2 3 4 6 7 8 9 5 10
result:
ok qwq
Test #8:
score: 0
Accepted
time: 23ms
memory: 57700kb
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 2 3 4 5 6 7 8 9 10
result:
ok qwq
Test #9:
score: -100
Wrong Answer
time: 25ms
memory: 57604kb
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 4 5 3 6 7 8 10 12 11 13 9 14 15 2
result:
wrong answer Changed color too many times (3)