QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#561624#9189. Make them Meetucup-team0040 0ms3756kbC++201.2kb2024-09-13 02:33:142024-09-13 02:33:14

Judging History

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

  • [2024-09-13 02:33:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3756kb
  • [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;
}

Details

Tip: Click on the bar to expand more detailed information

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%