QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#533631 | #8544. Colorful Graph 2 | rotcar07 | WA | 0ms | 8316kb | C++14 | 671b | 2024-08-26 09:27:17 | 2024-08-26 09:27:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
vector<int> e[maxn];
int col[maxn];
void dfs(int p,int co){
if(!~col[p]) col[p]=co;
else return;
for(auto x:e[p]) dfs(x,co^1);
}
inline void solve(){
int n,m;cin>>n>>m;
if(!m){
for(int i=1;i<=n;i++) cout<<"BR"[i&1];cout<<'\n';
return ;
}
for(int i=1;i<=n;i++) e[i].clear(),col[i]=-1;
for(int i=1,u,v;i<=m;i++) cin>>u>>v,u++,v++,e[u].push_back(v),e[v].push_back(u);
for(int i=1;i<=n;i++) if(!~col[i]) dfs(i,0);
for(int i=1;i<=n;i++) cout<<"BR"[col[i]];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: 0ms
memory: 8316kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RBR BBBR BBRBBB
result:
wrong answer cycle detected (test case 3)