QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567272 | #8544. Colorful Graph 2 | ggggggg | WA | 2ms | 8668kb | C++14 | 764b | 2024-09-16 10:43:16 | 2024-09-16 10:43:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m,f[N];
vector<int> G[N];
void solve(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) G[i].clear();
for(int i=1;i<n;i++) G[i].push_back(i+1),G[i+1].push_back(i);
G[1].push_back(n),G[n].push_back(1);
for(int i=1,x,y;i<=m;i++){
scanf("%d%d",&x,&y);
G[x].push_back(y),G[y].push_back(x);
}
queue<int> q;
for(int i=1;i<=n;i++) f[i]=0;
f[1]=1,q.push(1);
while(!q.empty()){
int u=q.front();
q.pop();
for(auto v:G[u]) if(!f[v]) f[v]=f[u]+1,q.push(v);
}
for(int i=1;i<=n;i++) putchar(f[i]%2==0?'R':'B');
puts("");
}
int main(){
int T;
scanf("%d",&T);
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8668kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BRR BRRR BRBBBR
result:
wrong answer cycle detected (test case 2)