QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601941 | #8544. Colorful Graph 2 | ucup-team4153 | WA | 41ms | 3536kb | C++17 | 1.2kb | 2024-09-30 16:23:36 | 2024-09-30 16:23:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
bool vis[N];
char res[N];
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)vis[i]=false;
for(int i=0;i<m;i++){
int u,v;cin>>u>>v;
vis[u]=vis[v]=true;
}
vector<int>vec;
for(int i=0;i<n;i++){
if(vis[i]){
vec.push_back(i);
}
}
if(vec.empty()){
res[0]='B';
for(int i=1;i<n;i++)res[i]='R';
}else{
for(int i=0;i<vec.size();i++){
if(i&1)res[vec[i]]='R';
else res[vec[i]]='B';
}
for(int i=0;i<n;i++){
if(vis[i])continue;
if(vis[(i+1)%n]){
if(res[(i+1)%n]=='B')res[i]='R';
else res[i]='B';
}else{
res[i]='B';
}
}
}
for(int i=0;i<n;i++)cout<<res[i];
cout<<'\n';
}
return 0;
}
/*
4 2 7
1 2 0
2 3 0
3 4 0
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BRR RBBR BBRRBR
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 41ms
memory: 3536kb
input:
100000 9 6 2 0 4 6 3 6 0 6 0 7 2 6 3 0 5 2 2 4 2 0 6 3 1 5 4 1 2 4 9 6 3 1 6 4 8 1 3 6 1 6 8 6 3 0 7 4 3 0 4 0 6 4 3 1 7 4 5 1 5 0 3 1 1 4 4 1 1 3 6 3 2 4 4 0 2 0 6 3 3 0 1 3 5 3 7 4 0 5 2 5 5 1 3 5 8 5 4 1 5 1 5 0 1 3 5 7 3 0 8 5 0 2 4 6 0 6 0 3 4 0 8 5 5 1 1 4 5 0 3 1 5 7 3 0 10 7 0 2 9 2 5 8 3 9 ...
output:
BBRBRRBRR BRR BBRRB RBRRBR RBBRBBRRB BRR BRRBRRB BRRBRBR RBBR BBRRBR BRRBBR BRBRRBR BRRBRBBR BRR BBRBRRBR BRRBRBBR BRR BBRBRBRRBR RBBRBBRB RBRBRBBRBR RBRBRRBRBR BBRBRRBRRB BRR RBRRBBR RBBRBR BBRRBRBR RBBR BBRBBRB RBRBRRBRBR RBRBBRB RBRRBBRB RBBRBR BBRRBR BRR BRR RBBRBBRBR BRBBRRB BRRBR RBRBBRBBRB BR...
result:
wrong answer cycle detected (test case 22)