QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#561624 | #9189. Make them Meet | ucup-team004 | 0 | 0ms | 3756kb | C++20 | 1.2kb | 2024-09-13 02:33:14 | 2024-09-13 02:33:14 |
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M;
std::cin >> N >> M;
std::vector<std::vector<int>> adj(N);
for (int i = 0; i < M; i++) {
int u, v;
std::cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
std::vector<bool> vis(N);
std::vector<int> dep(N), p(N);
p[0] = -1;
auto dfs = [&](auto &self, int x) -> void {
vis[x] = true;
for (auto y : adj[x]) {
if (!vis[y]) {
p[y] = x;
self(self, y);
}
}
};
dfs(dfs, 0);
std::cout << 2 * N << "\n";
for (int i = 0; i < 2 * N; i++) {
for (int x = 0; x < N; x++) {
int c;
if (dep[x] % 2 == i % 2) {
c = x;
} else if (x != 0) {
c = p[x];
} else {
c = adj[x][0];
}
std::cout << c << " \n"[x == N - 1];
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3596kb
input:
2 1 0 1
output:
4 0 1 1 0 0 1 1 0
result:
wrong answer If people start at 0 and 1, then they can avoid each other
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3756kb
input:
2 1 0 1
output:
4 0 1 1 0 0 1 1 0
result:
wrong answer If people start at 0 and 1, then they can avoid each other
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
2 1 0 1
output:
4 0 1 1 0 0 1 1 0
result:
wrong answer If people start at 0 and 1, then they can avoid each other
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%