QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#533639 | #8544. Colorful Graph 2 | rotcar07 | WA | 1ms | 8424kb | C++14 | 649b | 2024-08-26 09:44:17 | 2024-08-26 09:44:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
vector<int> e[maxn];
int col[maxn];
inline void solve(){
int n,m;cin>>n>>m;
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,e[u].push_back(v),e[v].push_back(u);
for(int i=1;i<=n;i++) e[i].push_back(i%n+1),e[i%n+1].push_back(i);
queue<int> q;q.push(1);col[1]=0;
while(!q.empty()){
int p=q.front();q.pop();
for(auto x:e[p]) if(!~col[x]) col[x]=col[p]^1,q.push(x);
}
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: 1ms
memory: 8424kb
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)