QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#393010 | #8544. Colorful Graph 2 | ucup-team2894 | WA | 1ms | 3916kb | C++17 | 2.0kb | 2024-04-18 02:57:36 | 2024-04-18 02:57:37 |
Judging History
answer
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(a) (a).begin(), (a).end()
using namespace std;
#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)
void solve() {
int T;
cin >> T;
while(T--) {
int N, M;
cin >> N >> M;
vector<set<int>> graph(N + 5);
for (int i = 0; i < N; i++) {
graph[i].insert((i + 1)%N);
graph[(i + 1)%N].insert(i);
}
for (int i = 1; i <= M; i++) {
int a, b;
cin >> a >> b;
graph[a].insert(b);
graph[b].insert(a);
}
set<int> st;
vector<int> stk;
for (int n = 0; n < N; n++) {
st.insert(n);
if (graph[n].size() == 2 && stk.size() < N - 2) {
stk.push_back(n);
}
}
int idx = 0;
while(st.size() > 2) {
int n = stk[idx++];
st.erase(n);
for (int e : graph[n]) {
if (graph[e].size() == 3) {
stk.push_back(e);
}
if (graph[e].size() > 2) {
graph[e].erase(n);
}
}
}
vector<int> clr(N + 5);
while(stk.size()) {
int n = stk.back();
stk.pop_back();
cout << n << " " << graph[n].size() << endl;
// cout << graph[n].size() << endl;
assert(graph[n].size() == 2);
if (!clr[*graph[n].begin()] && !clr[*next(graph[n].begin())]) {
clr[n] = 1;
}
}
for (int i = 0; i < N; i++) {
cout << "BR"[clr[i]];
}
cout << "\n";
}
}
int main() {
#ifdef ONPC
freopen("../a.in", "r", stdin);
// freopen("../a.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed;
cout.precision(20);
solve();
cerr << "\n\nConsumed " << TIME << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3916kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
0 2 RBB 3 2 1 2 2 2 0 2 BBBR 4 2 0 2 2 2 5 2 3 2 1 2 BRBBRB
result:
wrong answer Token parameter [name=S] equals to "0", doesn't correspond to pattern "[BR]{1,200000}" (test case 1)