QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#388831#8544. Colorful Graph 2ucup-team1303#WA 2ms3664kbC++201.7kb2024-04-13 20:40:482024-04-13 20:40:50

Judging History

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

  • [2024-04-13 20:40:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2024-04-13 20:40:48]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\033[33m[" << __LINE__ << "]\033[0m "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1e6 + 10;
vector <int> v[N];
bool vis[N];
void zhk() {
	int n, m;
	read(n), read(m);
	F(i, 1, n) v[i].push_back(i % n + 1), v[i % n + 1].push_back(i);
	F(i, 1, m) {
		int x, y; read(x), read(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	if (n % 2 == 0) {
		F(i, 1, n)
			if (i & 1) cout << 'B';
			else cout << 'R';
		cout << '\n';
		return;
	}
	F(i, 1, n) {
		for (int a: v[i]) vis[a] = true;
		bool flag = true;
		for (int b: v[i % n + 1]) {
			if (vis[b]) {
				if ((b - i + n) % 2 == 0) {
					flag = false;
					break;
				}
			}
			vis[b] = true;
		}
		for (int a: v[i]) vis[a] = false;
		for (int b: v[i % n + 1]) vis[b] = false;
		if (flag) {
			F(j, 1, n)
				if (((j + n - i) % n) % 2 == 0) cout << 'B';
				else cout << 'R';
			cout << '\n';
			return;
		}
	}
	assert(false);
}
signed main() {
	int _ = 1;
	cin >> _;
	while (_--) zhk();
	return 0;
}
/* why?
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3664kb

input:

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

output:

BRB
BRBR
BRBRBR

result:

wrong answer cycle detected (test case 3)