QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310840 | #4996. Icy Itinerary | sumi007 | WA | 0ms | 17728kb | C++14 | 1014b | 2024-01-21 18:48:57 | 2024-01-21 18:48:59 |
Judging History
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];
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 x:vec[0]) cout << x << ' ';
for(int x:vec[1]) cout << x << ' ';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 17652kb
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: 17644kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 17728kb
input:
10 10 7 8 7 5 5 2 6 1 10 7 4 6 5 8 3 2 10 5 1 10
output:
8 2 1 4 5 6 7 3 9 10
result:
wrong answer The first number wasn't 1