QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572646 | #8544. Colorful Graph 2 | wangjingheng | WA | 0ms | 3588kb | C++14 | 737b | 2024-09-18 15:48:49 | 2024-09-18 15:48:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,m;cin>>n>>m;
vector<int> c(n+1);
vector<pair<int,pair<int,int> > > g;
for(int i=1;i<=m;i++){
int u,v;cin>>u>>v;
int x=(u-v)%n;
x=(x+n)%n;
int y=(v-u)%n;
y=(y+n)%n;
if(x<=y){
g.push_back({x,{v,u}});
}
}
sort(g.begin(),g.end());
for(auto [_,e]:g){
auto [u,v]=e;
if(c[u]&&c[v]) continue;
if(c[u]){
c[v]=3-c[u];
}
else if(c[v]){
c[u]=3-c[v];
}
else{
c[u]=1,c[v]=2;
}
}
for(int i=0;i<n;i++){
if(c[i]==1){
cout<<"B";
}
else{
cout<<"R";
}
cout<<"\n";
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
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: 3588kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
R R R R R R B R R R R R R
result:
wrong answer the length doesn't equal n (test case 1)