QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660425 | #8544. Colorful Graph 2 | hjxddl# | WA | 0ms | 3820kb | C++20 | 1.1kb | 2024-10-20 11:07:21 | 2024-10-20 11:07:21 |
Judging History
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)