QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390801#8544. Colorful Graph 2Core_65536WA 0ms3528kbC++171.2kb2024-04-15 22:08:032024-04-15 22:08:04

Judging History

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

  • [2024-04-15 22:08:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3528kb
  • [2024-04-15 22:08:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

void solve()
{
    int n,m;    cin>>n>>m;
    vector<vector<int>> v(n);
    for(int i=0;i<n;i++)
        v[i].push_back((i+1)%n), v[i].push_back((i-1+n)%n);
    for(int i=0;i<m;i++)
    {
        int x,y;    cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    //Start BFS
    vector<int> vis(n+5,0);
    queue<int> q;
    q.push(0);
    vis[0]=1;
    //BFS
    vector<pair<int,bool>> ans;  ans.push_back({0,1});
    bool color=0;   //0:Black 1:Red
    while(!q.empty()){
        int Qfro = q.front();
        for(int i=0;i<v[Qfro].size();i++){
            int ThisDes = v[Qfro][i];
            if(!vis[ThisDes]){
                vis[ThisDes]=1;
                ans.push_back({ThisDes,color});
                q.push(ThisDes);
                color = !color;
            }
        }
        q.pop();
    }
    sort(ans.begin(),ans.end());
    for(auto i:ans){
        if(i.second)    cout<<'R';
        else    cout<<'B';
    }
    cout<<endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=1;    cin>>T;
    while(T--)  solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3528kb

input:

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

output:

RBR
RBBR
RBBBRR

result:

wrong answer cycle detected (test case 3)