QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392000#8544. Colorful Graph 2Giga_Cronos#WA 1ms3580kbC++20999b2024-04-17 01:08:152024-04-17 01:08:16

Judging History

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

  • [2024-04-17 01:08:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3580kb
  • [2024-04-17 01:08:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) (x).begin(),(x).end()
#define pb push_back


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
vi C;
vvi G;
void DFS(int u){
    for(auto v:G[u])if(!C[v]){
        C[v]=3-C[u];
        DFS(v);
    }
}


void problem()
{
    int n, m;
    cin >> n >> m;
    C.assign(n,0);
    G.assign(n,vi());
    for(int i=0;i<n;i++){
        G[i].pb({(i+1)%n});
        G[(i+1)%n].pb({i});
    }
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    C[0]=1;
    DFS(0);
    for(auto a:C){
        if(a==1){
            cout<<"R";
        }else{
            cout<<"B";
        }
    }

}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin>>tc;
    while(tc--){
        problem();
        cout<<"\n";
    }
   
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3580kb

input:

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

output:

RBR
RBRB
RBRBRB

result:

wrong answer cycle detected (test case 3)