QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#611452#8544. Colorful Graph 2juneeWA 4ms16060kbC++141.1kb2024-10-04 21:03:502024-10-04 21:03:54

Judging History

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

  • [2024-10-04 21:03:54]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:16060kb
  • [2024-10-04 21:03:50]
  • 提交

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]=3-c[u];
				q.push(i.second);
			}
		}
		for(int i=1;i<=n;i++){
			if(c[i]==1)cout<<"R";
			else cout<<'B';
		}
		cout<<'\n';
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 16060kb

input:

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

output:

RBB
RBBB
RBBBBB

result:

wrong answer cycle detected (test case 2)