QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398604#8544. Colorful Graph 2gqf123RE 0ms0kbC++201.0kb2024-04-25 15:37:452024-04-25 15:37:48

Judging History

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

  • [2024-04-25 15:37:48]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-25 15:37:45]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
vector<int>to[200000];
inline void solve() {
	int n, m;
	cin >> n >> m;
	string s(n, ' ');
	for (int i = 0; i ^ n; ++i) {
		to[i].clear();
	}
	for (int i = 0; i ^ m; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].emplace_back(v);
		to[v].emplace_back(u);
	}
	for (int i = 0; i ^ n; ++i) {
		to[i].emplace_back((i + 1) % n);
		to[(i + 1) % n].emplace_back(i);
	}
	queue<int>q;
	q.emplace(0);
	s[0] = 'B';
	for (; q.size();) {
		int u = q.front();
		q.pop();
		for (const auto& v : to[u]) {
			if (s[v] != ' ') {
				continue;
			}
			if (s[u] == 'B') {
				s[v] = 'R';
			}
			else {
				s[v] = 'B';
			}
			q.emplace(v);
		}
	}
	cout << s << '\n';
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	for (; t--;) {
		solve();
	}
}
/*
6 7
1 2
1 3
2 4
3 5
2 6
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
6 1 2 6 4 3 5
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:


result: