QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#611452 | #8544. Colorful Graph 2 | junee | WA | 4ms | 16060kb | C++14 | 1.1kb | 2024-10-04 21:03:50 | 2024-10-04 21:03:54 |
Judging History
answer
#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<random>
#include<chrono>
#include<queue>
#include<vector>
#include<unordered_map>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
const int N=2e5+10;
int T,n,m;
int d[N];
int c[N];
queue<int>q;
unordered_map<int,int>mp[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>m;
for(int i=1;i<=n;i++){
c[i]=0;
if(i!=n)mp[i].insert({i+1,i+1});
else mp[i].insert({1,1});
if(i!=1)mp[i].insert({i-1,i-1});
else mp[i].insert({n,n});
}
for(int i=1,x,y;i<=m;i++){
cin>>x>>y;
x++,y++;
mp[x].insert({y,y});
mp[y].insert({x,x});
}
q.push(1);
c[1]=1;
while(q.size()){
int u=q.front();
q.pop();
for(auto i:mp[u]){
if(c[i.second])continue;
c[i.second]=3-c[u];
q.push(i.second);
}
}
for(int i=1;i<=n;i++){
if(c[i]==1)cout<<"R";
else cout<<'B';
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 16060kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RBB RBBB RBBBBB
result:
wrong answer cycle detected (test case 2)