QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#533639#8544. Colorful Graph 2rotcar07WA 1ms8424kbC++14649b2024-08-26 09:44:172024-08-26 09:44:17

Judging History

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

  • [2024-08-26 09:44:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8424kb
  • [2024-08-26 09:44:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
vector<int> e[maxn];
int col[maxn];  
inline void solve(){
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) e[i].clear(),col[i]=-1;
    for(int i=1,u,v;i<=m;i++) cin>>u>>v,e[u].push_back(v),e[v].push_back(u);
    for(int i=1;i<=n;i++) e[i].push_back(i%n+1),e[i%n+1].push_back(i);
    queue<int> q;q.push(1);col[1]=0;
    while(!q.empty()){
        int p=q.front();q.pop();
        for(auto x:e[p]) if(!~col[x]) col[x]=col[p]^1,q.push(x);
    }
    for(int i=1;i<=n;i++) cout<<"BR"[col[i]];cout<<'\n';
}
int main(){
    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: 1ms
memory: 8424kb

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)