QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309835#8130. Yet Another Balanced Coloring Problemucup-team027#WA 1ms3504kbC++23616b2024-01-20 21:14:402024-01-20 21:14:40

Judging History

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

  • [2024-03-18 02:37:14]
  • hack成功,自动添加数据
  • (/hack/577)
  • [2024-01-20 21:14:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3504kb
  • [2024-01-20 21:14:40]
  • 提交

answer

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

void solve() {
	int n, m; cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < n-1; i++) {
		int j; cin >> j; j--;
		g[i].push_back(j);
		g[j].push_back(i);
	}
	for (int i = 0; i < m-1; i++) {
		int j; cin >> j;
	}

	int k = 0;
	for (int i = 0; i < n-1; i++) {
		if (g[i].size() == 1) k++;
		else break;
	}

	for (int i = 0; i < k; i++) {
		if (i % 2) cout << "B"; else cout << "R";
	}
	cout << '\n';
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int t; cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3504kb

input:

2
7 7
5 5 6 6 7 7
5 6 5 6 7 7
5 4
4 4 5 5
4 4 4

output:

RBRB
RBR

result:

wrong answer charge of vertex 5 in tree 2 violates range (test case 1)