QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#807920 | #8544. Colorful Graph 2 | ucup-team2179# | WA | 57ms | 3632kb | C++23 | 1.1kb | 2024-12-10 14:41:28 | 2024-12-10 14:41:32 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ll long long
using namespace std;
const int maxn = 2e5 + 10;
vector<pii> G[maxn];
char ans[maxn];
int col[maxn];
void dfs(int u, int f) {
for (auto [w, v] : G[u]) {
if (col[v] == -1) {
col[v] = col[u] ^ 1;
dfs(v, u);
}
}
}
void solve() {
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++) G[i].clear(), col[i] = -1;
for (int i = 0; i < n; i++) {
G[i].emplace_back(1, (i + 1) % n);
G[(i + 1) % n].emplace_back(1, i);
}
while (m--) {
int u, v; cin >> u >> v;
G[u].emplace_back(0, v);
G[v].emplace_back(0, u);
}
for (int i = 0; i < n; i++)
sort(G[i].begin(), G[i].end());
col[0] = 0;
dfs(0, 0);
for (int i = 0; i < n; i++)
if (col[i] == 0) cout << 'B';
else cout << 'R';
cout << "\n";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BRB BRRB BBRRBR
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 57ms
memory: 3632kb
input:
100000 9 6 2 0 4 6 3 6 0 6 0 7 2 6 3 0 5 2 2 4 2 0 6 3 1 5 4 1 2 4 9 6 3 1 6 4 8 1 3 6 1 6 8 6 3 0 7 4 3 0 4 0 6 4 3 1 7 4 5 1 5 0 3 1 1 4 4 1 1 3 6 3 2 4 4 0 2 0 6 3 3 0 1 3 5 3 7 4 0 5 2 5 5 1 3 5 8 5 4 1 5 1 5 0 1 3 5 7 3 0 8 5 0 2 4 6 0 6 0 3 4 0 8 5 5 1 1 4 5 0 3 1 5 7 3 0 10 7 0 2 9 2 5 8 3 9 ...
output:
BBRRBRBRB BRB BBRRB BRRBBR BRRBBRRRB BRB BBRRBBR BBBRBRB BRRB BBRRBR BBRRRB BBRBRRB BBBRBRRB BRB BBRBRRBR BBBRBRRB BRB BBRRBBRBRB BRRBBRRB BRRBBRRBRB BRRRRBBBBR BBRBBBRRRB BRB BRRBBBR BRRBRB BBRRBRBR BRRB BBRRRBB BRRRBRBRBB BRRRBBB BRRBBBRB BRRBRB BBRRBR BRB BRB BRRBRRBRB BBRBRRB BBRRB BRRBRBBBRR BB...
result:
wrong answer cycle detected (test case 22)