QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#533631#8544. Colorful Graph 2rotcar07WA 0ms8316kbC++14671b2024-08-26 09:27:172024-08-26 09:27:17

Judging History

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

  • [2024-08-26 09:27:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:8316kb
  • [2024-08-26 09:27:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
vector<int> e[maxn];
int col[maxn];
void dfs(int p,int co){
    if(!~col[p]) col[p]=co;
    else return;
    for(auto x:e[p]) dfs(x,co^1);
}
inline void solve(){
    int n,m;cin>>n>>m;
    if(!m){
        for(int i=1;i<=n;i++) cout<<"BR"[i&1];cout<<'\n';
        return ;
    }
    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,u++,v++,e[u].push_back(v),e[v].push_back(u);
    for(int i=1;i<=n;i++) if(!~col[i]) dfs(i,0);
    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: 0ms
memory: 8316kb

input:

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

output:

RBR
BBBR
BBRBBB

result:

wrong answer cycle detected (test case 3)