QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626943 | #8544. Colorful Graph 2 | ucup-team4479# | WA | 52ms | 3672kb | C++23 | 964b | 2024-10-10 14:07:52 | 2024-10-10 14:07:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m;
vector<int>G[N];
int col[N];
void dfs(int u,int color)
{
if(col[u]!=-1) return;
col[u]=color;
for(int v:G[u])
dfs(v,color^1);
return;
}
void solve()
{
cin>>n>>m;
for(int i=0;i<n;i++)
G[i].clear(),col[i]=-1;
for(int i=0;i<m;i++)
{
int u,v;
cin>>u>>v;
G[u].emplace_back(v);
G[v].emplace_back(u);
}
for(int i=0;i<n;i++)
{
int j=(i+1)%n;
G[i].emplace_back(j);
G[j].emplace_back(i);
}
dfs(0,1);
for(int i=0;i<n;i++)
if(col[i]==-1) col[i]=0;
for(int i=0;i<n;i++)
if(col[i]) cout<<"B";
else cout<<"R";
cout<<"\n";
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int T;
cin>>T;
while(T--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
BRB BRRB BBRRBR
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 52ms
memory: 3672kb
input:
100000 9 6 2 0 4 6 3 6 0 6 0 7 2 6 3 0 5 2 2 4 2 0 6 3 1 5 4 1 2 4 9 6 3 1 6 4 8 1 3 6 1 6 8 6 3 0 7 4 3 0 4 0 6 4 3 1 7 4 5 1 5 0 3 1 1 4 4 1 1 3 6 3 2 4 4 0 2 0 6 3 3 0 1 3 5 3 7 4 0 5 2 5 5 1 3 5 8 5 4 1 5 1 5 0 1 3 5 7 3 0 8 5 0 2 4 6 0 6 0 3 4 0 8 5 5 1 1 4 5 0 3 1 5 7 3 0 10 7 0 2 9 2 5 8 3 9 ...
output:
BBRBRBBRB BRB BBRRB BRBRRB BRRBBRRRB BRB BBRRBBR BBBRBRB BRRB BRBRRB BBRRRB BRBRBRB BBRBRRRB BRB BBRBRRBR BBRBRRRB BRB BBRRBBRBRB BRBRBRRB BRRBBRRBRB BRBBBRRRRB BBRBRRBBRR BRB BRBRRBB BRBRBR BBRRBRBR BRRB BBRRRBB BRRRBRRBRB BRRRBBB BRBRRBBR BRRBRB BBRRBR BRB BRB BRRBRBRBR BRBRRRB BBRRB BRRBRBBBRR BB...
result:
wrong answer cycle detected (test case 19)