QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395322#8544. Colorful Graph 2ucup-team052#WA 155ms3700kbC++23915b2024-04-21 13:18:302024-04-21 13:18:30

Judging History

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

  • [2024-04-21 13:18:30]
  • 评测
  • 测评结果:WA
  • 用时:155ms
  • 内存:3700kb
  • [2024-04-21 13:18:30]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define D(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
using LL=long long;
const int N=200005;
int T,n,m,idx;
vector<int>e[N];
int ans[N];
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	cin>>T;
	while(T--){
		cin>>n>>m;
		rep(i,0,n-1)e[i].clear();
		rep(i,0,n-1){
			e[i].pb((i+1)%n);
			e[(i+1)%n].eb(i);
		}
		rep(i,0,m-1){
			int u,v;
			cin>>u>>v;
			e[u].pb(v),e[v].pb(u);
		}
		rep(i,0,n-1)ans[i]=1e9;
		ans[0]=0;
		queue<int>que;
		que.push(0);
		while(!que.empty()){
			int u=que.front();
			que.pop();
			for(auto&x:e[u])if(ans[u]+1<ans[x])ans[x]=ans[u]+1,que.push(x);
		}
		
		rep(i,1,n)printf("%c",ans[i]&1?'B':'R');
		puts("");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3588kb

input:

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

output:

BBR
BRBR
BBRBBR

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 155ms
memory: 3700kb

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:

BBRRRBBBR
BBR
BBRBR
BRBRBB
BRRBBRRBR
BBR
BRBBRBR
BRRRBBR
BRBR
BBRBBB
BRBRBB
BRRRBBR
BRRRBRBB
BBR
BBBBRBBB
BRRRBRBB
BBR
BBRRBBBRBR
BRRBBRBR
BRRBBRBRBR
BRBRBRBRBR
BBBRBBRRBR
BBB
BRBRRBR
BRRRBB
BBRRRRBR
BRBR
BBRBRBB
BRBRRBBRBR
BRBBRBB
BRBRBRBR
BRRRBR
BBRBBR
BBR
BBR
BRRRBBRBB
BRRBRBR
BRBBR
BRBBRRBRBR
BR...

result:

wrong answer cycle detected (test case 1)