QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#645978#8544. Colorful Graph 2bruteforce_WA 0ms3660kbC++20966b2024-10-16 20:44:032024-10-16 20:44:04

Judging History

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

  • [2024-10-16 20:44:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3660kb
  • [2024-10-16 20:44:03]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+7,inf=1e18,mod=998244353;
void O_o()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> e(n+1,vector<int>());
	for(int i=1; i<=m; i++)
	{
		int x,y;
		cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i=1; i<n; i++)
	{
		e[i].push_back(i+1);
		e[i+1].push_back(i);
	}
	e[1].push_back(n);
	e[n].push_back(1);
	vector<bool> vis(n+1);
	queue<int> q;
	q.push(1); 
	vector<bool> ans(n+1);
	vis[1]=1;
	while(q.size())
	{
		int u=q.front(); q.pop();
		for(auto v:e[u])
		{
			if(vis[v]) continue;
			vis[v]=1;
			ans[v]=ans[u]^1;
			q.push(v);
		}
	}
	for(int i=1; i<=n; i++)
	{
		if(ans[i])
			cout<<"R";
		else
			cout<<"B";
	}
	cout<<"\n";
}
signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout<<fixed<<setprecision(12);
	int T=1;
	cin>>T;
	while(T--)
	{
		O_o();
	}
}














Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3660kb

input:

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

output:

BRR
BRRR
BRBBBR

result:

wrong answer cycle detected (test case 2)