QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#128242 | #4996. Icy Itinerary | Hanx16Msgr | WA | 1ms | 3520kb | C++14 | 1.1kb | 2023-07-20 19:18:08 | 2023-07-20 19:18:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int _N = 3e5 + 5;
int n, m;
map<pair<int, int>, bool> H;
void AddEdge(int x, int y) { H[{x, y}] = H[{y, x}] = 1; }
bool Check(int x, int y) { return H.count({x, y}); }
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1, x, y; i <= m; ++i)
cin >> x >> y, AddEdge(x, y);
vector<int> q1, q2;
q1.emplace_back(1), q2.emplace_back(2);
for (int i = 3; i <= n; ++i) {
int x = -1, y = -1;
if (!q1.empty()) x = q1.back();
else { q1.emplace_back(i); continue; }
if (!q2.empty()) y = q2.back();
else { q2.emplace_back(i); continue; }
if (Check(i, x)) q1.emplace_back(i);
else if (!Check(i, y)) q2.emplace_back(i);
else {
if (Check(x, y)) {
q2.pop_back();
q1.emplace_back(y);
q1.emplace_back(i);
} else {
q1.pop_back();
q2.emplace_back(x);
q2.emplace_back(i);
}
}
}
for (int x : q1) cout << x << ' ';
for (int x : q2) cout << x << ' ';
cout << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3484kb
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: 1ms
memory: 3452kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3520kb
input:
10 10 7 8 7 5 5 2 6 1 10 7 4 6 5 8 3 2 10 5 1 10
output:
9 2 1 3 5 6 7 4 8 10
result:
wrong answer The first number wasn't 1