QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#611446 | #8544. Colorful Graph 2 | junee | WA | 85ms | 15136kb | C++14 | 1.1kb | 2024-10-04 21:03:13 | 2024-10-04 21:03:13 |
Judging History
answer
#include<iostream>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<random>
#include<chrono>
#include<queue>
#include<vector>
#include<unordered_map>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
const int N=2e5+10;
int T,n,m;
int d[N];
int c[N];
queue<int>q;
unordered_map<int,int>mp[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>m;
for(int i=1;i<=n;i++){
c[i]=0;
if(i!=n)mp[i].insert({i+1,i+1});
else mp[i].insert({1,1});
if(i!=1)mp[i].insert({i-1,i-1});
else mp[i].insert({n,n});
}
for(int i=1,x,y;i<=m;i++){
cin>>x>>y;
x++,y++;
mp[x].insert({y,y});
mp[y].insert({x,x});
}
q.push(1);
c[1]=1;
while(q.size()){
int u=q.front();
q.pop();
for(auto i:mp[u]){
if(c[i.second])continue;
c[i.second]=c[u]^1;
q.push(i.second);
}
}
for(int i=1;i<=n;i++){
if(c[i])cout<<"R";
else cout<<'B';
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 15136kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
RRB RRRB RBRRBR
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 85ms
memory: 14572kb
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:
RRBRBRRBR RRB RBRRB RRBRRB RRBRRBRBR RRB RRRBRBR RRRBRBR RRRB RRRBRB RRRBRR RRRBRRR RRRBRRRB RRR RRRBRRRB RRRBRRRB RRR RRRRRBRRRB RRRRRBRR RRRRRBRRRB RRRRRBRRRB RRRRRBRRRB RRR RRRRRBR RRRRRB RRRRRBRR RRRR RRRRRBR RRRRRBRRRB RRRRRBR RRRRRBRR RRRRRB RRRRRB RRR RRR RRRRRBRRR RRRRRBR RRRRR RRRRRRRRRB RR...
result:
wrong answer cycle detected (test case 5)