QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545529 | #8544. Colorful Graph 2 | Kir1same | WA | 0ms | 52048kb | C++14 | 1.3kb | 2024-09-03 14:43:09 | 2024-09-03 14:43:09 |
Judging History
answer
#include <bits/stdc++.h>
// #pragma GCC optimize(3,"Ofast","inline")
using namespace std;
typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
void init();
#define Clear(a) memset(a, 0, sizeof(a))
#define pb(x) push_back(x)
#define INF 1e9 + 10
const int N = 2e6 + 10;
const int M = 3e4 + 10;
const ll mod = 1e9 + 7;
const bool IN_TEST = 1;
vector<int> from[N];
int dep[N];
void dfs(int u,int fa){
for (int v:from[u]){
if (v==fa || dep[v]) continue;
dep[v] = dep[u]+1;
dfs(v,u);
}
}
void solve(){
int n,m;
cin>>n>>m;
for (int i=0;i<=n;i++) from[i].clear(), dep[i]=0;
for (int i=0;i<n;i++){
int v=(i+1)%n;
from[i].pb(v);
from[v].pb(i);
}
for (int i=0;i<m;i++){
int u,v;
cin>>u>>v;
from[u].pb(v);
from[v].pb(u);
}
dep[0] = 1;
dfs(0,-1);
for (int i=0;i<n;i++){
if (dep[i]&1) cout<<"R";
else cout<<"B";
}
cout<<endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
int t = 1;
if (IN_TEST)
cin >> t;
while (t--)
solve();
return 0;
}
void init()
{
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 52048kb
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)