QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572646#8544. Colorful Graph 2wangjinghengWA 0ms3588kbC++14737b2024-09-18 15:48:492024-09-18 15:48:49

Judging History

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

  • [2024-09-18 15:48:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-09-18 15:48:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solve(){
	int n,m;cin>>n>>m;
	vector<int> c(n+1);
	vector<pair<int,pair<int,int> > > g;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		int x=(u-v)%n;
		x=(x+n)%n;
		int y=(v-u)%n;
		y=(y+n)%n;
		if(x<=y){
			g.push_back({x,{v,u}});
		}
	}
	sort(g.begin(),g.end());
	for(auto [_,e]:g){
		auto [u,v]=e;
		if(c[u]&&c[v]) continue;
		if(c[u]){
			c[v]=3-c[u];
		} 
		else if(c[v]){
			c[u]=3-c[v];
		}
		else{
			c[u]=1,c[v]=2;
		}
	}
	for(int i=0;i<n;i++){
		if(c[i]==1){
			cout<<"B";
		}
		else{
			cout<<"R";
		}
		cout<<"\n";
	}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
	int T;cin>>T;
	while(T--)
	solve(); 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

R
R
R
R
R
R
B
R
R
R
R
R
R

result:

wrong answer the length doesn't equal n (test case 1)