QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#567272#8544. Colorful Graph 2gggggggWA 2ms8668kbC++14764b2024-09-16 10:43:162024-09-16 10:43:16

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 10:43:16]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8668kb
  • [2024-09-16 10:43:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m,f[N];
vector<int> G[N];
void solve(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) G[i].clear();
    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,x,y;i<=m;i++){
        scanf("%d%d",&x,&y);
        G[x].push_back(y),G[y].push_back(x);
    }
    queue<int> q;
    for(int i=1;i<=n;i++) f[i]=0;
    f[1]=1,q.push(1);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(auto v:G[u]) if(!f[v]) f[v]=f[u]+1,q.push(v);
    }
    for(int i=1;i<=n;i++) putchar(f[i]%2==0?'R':'B');
    puts("");
}
int main(){
    int T;
    scanf("%d",&T);
    while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8668kb

input:

3
3 0
4 1
1 3
6 3
0 2
2 4
4 0

output:

BRR
BRRR
BRBBBR

result:

wrong answer cycle detected (test case 2)