QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672172 | #8544. Colorful Graph 2 | libantian# | WA | 1ms | 3536kb | C++23 | 1.2kb | 2024-10-24 15:55:43 | 2024-10-24 15:55:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
const int N=200010;
vector<int>g[N];
int st[N];
void solve(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
g[i].clear();
st[i]=-1;
}
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;i<=m;i++){
int x,y;
cin>>x>>y;
g[x].push_back(y);
g[y].push_back(x);
}
st[1]=1;
queue<pii>q;
q.push({1,1});
while(q.size()){
int u=q.front().fi;
int d=q.front().se;
q.pop();
for(auto v:g[u]){
if(st[v]!=-1)continue;
st[v]=d^1;
q.push({v,st[v]});
}
}
for(int i=1;i<=n;i++){
if(st[i])cout<<"R";
else cout<<"B";
}
cout<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cout << setiosflags(ios::fixed) << setprecision(15);
int T;
T=1;
cin>>T;
while(T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3536kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RBB RBBB RBRRRB
result:
wrong answer cycle detected (test case 2)