QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391767 | #8544. Colorful Graph 2 | xunxxxx | WA | 1ms | 5672kb | C++20 | 770b | 2024-04-16 19:26:30 | 2024-04-16 19:26:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<int>g[200010];
int n,m,u,v,ans[200010];
void solve()
{
cin>>n>>m;
for(int i=0;i<n;i++) g[i].clear();
vector<int>vt(n,0);
for(int i=0;i<n-1;i++)
{
g[i].push_back(i+1);
g[i+1].push_back(i);
}
g[n-1].push_back(0);
g[0].push_back(n-1);
for(int i=1;i<=m;i++)
{
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
queue<pair<int,int>>q;
q.push({0,0});
while(q.size())
{
u=q.front().first;
int l=q.front().second;
ans[u]=l;
vt[u]=1;
for(auto i:g[u])
{
if(vt[i]) continue;
q.push({i,l^1});
}
q.pop();
}
for(int i=0;i<n;i++) if(ans[i]) cout<<"R";
else cout<<"B";
cout<<"\n";
}
int main()
{
int t;
cin>>t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5672kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BRB BRBB BRBRBR
result:
wrong answer cycle detected (test case 3)