QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660425#8544. Colorful Graph 2hjxddl#WA 0ms3820kbC++201.1kb2024-10-20 11:07:212024-10-20 11:07:21

Judging History

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

  • [2024-10-20 11:07:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-10-20 11:07:21]
  • 提交

answer

// Coded by hjxddl
#include <bits/stdc++.h>
#define ll long long
#define db double
const int N = 2e5 + 5;
int n, m;
void solve() {
    std::cin >> n >> m;
    std::vector<std::vector<int>> e(n + 5);
    std::vector<int> col(n + 5);
    for (int i = 0; i < n - 1; i++) {
        e[i].push_back(i + 1);
        e[i + 1].push_back(i);
    }
    e[n - 1].push_back(0);
    e[0].push_back(n - 1);
    for (int i = 1; i <= m; i++) {
        int u, v;
        std::cin >> u >> v;
    }
    std::queue<std::pair<int, int>> q;
    q.push({0, 2});
    while (q.size()) {
        auto [x, z] = q.front();
        q.pop();
        if (col[x]) continue;
        col[x] = z;
        for (int y : e[x]) {
            if (col[y]) continue;
            q.push({y, z ^ 1});
        }
    }
    for (int i = 0; i < n; i++) {
        if (col[i] == 2)
            std::cout << "B";
        else
            std::cout << "R";
    }
    std::cout << '\n';
}
int main() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0), std::cout.tie(0);
    int t = 1;
    std::cin >> t;
    while (t--) {
        solve();
    }
    std::cout << std::flush;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3820kb

input:

3
3 0
4 1
1 3
6 3
0 2
2 4
4 0

output:

BRR
BRBR
BRBRBR

result:

wrong answer cycle detected (test case 3)