QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395321 | #8544. Colorful Graph 2 | ucup-team052# | WA | 146ms | 3732kb | C++23 | 903b | 2024-04-21 13:17:45 | 2024-04-21 13:17:46 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define D(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
using LL=long long;
const int N=200005;
int T,n,m,idx;
vector<int>e[N];
int ans[N];
int main(){
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
cin>>T;
while(T--){
cin>>n>>m;
rep(i,0,n-1)e[i].clear();
rep(i,0,n-1){
e[i].pb((i+1)%n);
e[(i+1)%n].eb(i);
}
rep(i,0,m-1){
int u,v;
cin>>u>>v;
e[u].pb(v),e[v].pb(u);
}
rep(i,0,n-1)ans[i]=1e9;
ans[0]=0;
queue<int>que;
que.push(0);
while(!que.empty()){
int u=que.front();
que.pop();
for(auto&x:e[u])if(ans[u]+1<ans[x])ans[x]=ans[u]+1;
}
rep(i,1,n)printf("%c",ans[i]&1?'B':'R');
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BBR BRBR BBRBBR
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 146ms
memory: 3676kb
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:
BBRRRBBBR BBR BBRBR BRRRBB BRRRRRRBR BBR BRBBRBR BRRRBBR BRBR BBRBBB BRBRBB BRRRBBR BRRRBRBB BBR BBBBRBBB BRRRBRBB BBR BBRRRRRRBR BRRRRRBR BRRRRRRRBR BRRRRRRRBR BBBRRRRRBR BBB BRRRRBR BRRRBB BBRRRRBR BRBR BBRRRBB BRRRRRRRBR BRRRRBR BRRRRRBR BRRRBR BBRBBR BBR BBR BRRRRRRBB BRRBRBR BRBBR BRRRRRRRBR BR...
result:
wrong answer cycle detected (test case 1)