QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#672172#8544. Colorful Graph 2libantian#WA 1ms3536kbC++231.2kb2024-10-24 15:55:432024-10-24 15:55:52

Judging History

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

  • [2024-10-24 15:55:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2024-10-24 15:55:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
const int N=200010;
vector<int>g[N];
int st[N];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        g[i].clear();
        st[i]=-1;
    }
    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;i<=m;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    st[1]=1;
    queue<pii>q;
    q.push({1,1});
    while(q.size()){
        int u=q.front().fi;
        int d=q.front().se;
        q.pop();
        for(auto v:g[u]){
            if(st[v]!=-1)continue;
            st[v]=d^1;
            q.push({v,st[v]});
        }
    }
    for(int i=1;i<=n;i++){
        if(st[i])cout<<"R";
        else cout<<"B";
    }
    cout<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << setiosflags(ios::fixed) << setprecision(15);
    int T;
    T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

RBB
RBBB
RBRRRB

result:

wrong answer cycle detected (test case 2)