QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#672221 | #8544. Colorful Graph 2 | ospoasa | WA | 0ms | 8496kb | C++14 | 1.7kb | 2024-10-24 16:03:30 | 2024-10-24 16:03:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5 + 10;
vector <int> G[N];
void solve()
{
int n, m;
cin >> n >> m;
vector <int> ck(n + 1);// i与i + 1
vector <char> ans(n + 1);
int u, v;
for(int i = 1; i <= m; i++) {
cin >> u >> v;
u++, v++;
G[u].push_back(v);
G[v].push_back(u);
}
if(n % 2 == 0) {
for(int i = 1; i <= n; i++) {
if(i % 2) cout << 'R';
else cout << 'B';
}
cout << '\n';
for(int i = 1; i <= n; i++) G[i].clear();
return;
}
for(int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
for(int i = 1; i <= n; i++) {
if(!G[i].size()) continue;
for(int j = 0; j < G[i].size() - 1; j++) {
if(G[i][j] == G[i][j + 1] - 1) ck[G[i][j]] = 1;
if(G[i][j] == 1 && G[i][j + 1] == n) ck[n] = 1;
}
}
for(int i = 1; i <= n; i++) {
if(!ck[i]) {
ans[i] = ans[i + 1] = 'R';
for(int j = 2; i + j <= n; j++) {
if(j % 2) ans[i + j] = 'R';
else ans[i + j] = 'B';
}
for(int j = 1; i - j >= 1; j++) {
if(j % 2) ans[i - j] = 'B';
else ans[i - j] = 'R';
}
for(int j = 1; j <= n; j++) cout << ans[j];
cout << '\n';
for(int i = 1; i <= n; i++) G[i].clear();
return;
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8496kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RRB RBRB RBRBRB
result:
wrong answer cycle detected (test case 3)