QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#638416 | #8544. Colorful Graph 2 | argtarg# | WA | 85ms | 3792kb | C++20 | 1.0kb | 2024-10-13 15:52:46 | 2024-10-13 15:52:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--)solve();
return 0;
}
//const int mod = 998244353;
void solve()
{
int n,m;
cin>>n>>m;
vector<vector<int>>g(n);
for(int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
g[x].push_back(y);
g[y].push_back(x);
}
for(int i=0;i<n;i++){
int x=i,y=(i+1)%n;
g[x].push_back(y);
g[y].push_back(x);
}
vector<int>vis(n);
queue<int>q;
q.push(0);
vis[0]=1;
vector<int>ans(n);
while(q.size()){
int u=q.front();
q.pop();
for(int j:g[u]){
if(vis[j])continue;
vis[j]=1;
ans[j]=ans[u]^1;
}
}
for(int i=0;i<n;i++)cout<<(ans[i]==1 ? "B":"R");
cout<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RBB RBRB RBBRBB
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 85ms
memory: 3792kb
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:
RBBRRRBBB RBB RBBRB RBRRRB RBRRRRRRB RBB RBRBBRB RBRRRBB RBRB RBBRBB RBRBRB RBRRRBB RBRRRBRB RBB RBBBBRBB RBRRRBRB RBB RBBRRRRRRB RBRRRRRB RBRRRRRRRB RBRRRRRRRB RBBBRRRRRB RBB RBRRRRB RBRRRB RBBRRRRB RBRB RBBRRRB RBRRRRRRRB RBRRRRB RBRRRRRB RBRRRB RBBRBB RBB RBB RBRRRRRRB RBRRBRB RBRBB RBRRRRRRRB RB...
result:
wrong answer cycle detected (test case 4)