Task: | Graph painting |
Sender: | LTR |
Submission time: | 2016-05-28 15:36:43 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.05 s | details |
#2 | WRONG ANSWER | 0.05 s | details |
#3 | ACCEPTED | 0.26 s | details |
Code
#include <iostream> #include <vector> #include <cstdio> int main() { int t; std::cin >> t; for (int ti = 0; ti < t; ++ti) { int n, m; std::cin >> n >> m; std::vector<std::vector<int>> E(n); std::vector<bool> visited(n, false); std::vector<bool> red(n, false); for (int mi = 0; mi < m; ++mi) { int a, b; std::cin >> a >> b; a--; b--; E[a].push_back(b); E[b].push_back(a); } std::vector<int> A; std::vector<int> B; int i0 = 0; bool isred = false; A.push_back(i0); while (i0 < n) { while (!A.empty()) { B.clear(); for (int a : A) { red[a] = isred; visited[a] = true; for (int aa : E[a]) { if (!visited[aa]) B.push_back(aa); } } A.swap(B); isred = !isred; } ++i0; while ((i0 < n) && visited[i0]) ++i0; } for (bool b : red) std::cout << (b ? "R" : "B") << " "; std::cout << std::endl; } }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
100 7 1 2 5 8 28 2 7 ... |
correct output |
---|
B R B B B B R R B B R B R B B R R B B B B R R R B B B R B R B B B B R B R R B R ... |
user output |
---|
B B B B B B B B B B R B B B B B R B R R R B R R R B B B B R B B R B B B R R R R ... |
Test 2
Verdict: WRONG ANSWER
input |
---|
10 38 36 18 28 20 37 22 38 ... |
correct output |
---|
R R B R B R R R R R B B R B R ... |
user output |
---|
B B R B B B B B B B B B B B B ... |
Test 3
Verdict: ACCEPTED
input |
---|
1 100000 200000 89300 98492 33853 56822 92967 99427 ... |
correct output |
---|
R R R R B R R R B B B R B B B ... |
user output |
---|
B B R R B B B R B R B R R B R ... |