Task: | Graph painting |
Sender: | Anonyymit Algoritmistit |
Submission time: | 2016-05-28 15:26:11 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.13 s | details |
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t; cin >> t; for(int j = 0; j < t; j++) { vector<vector<ll>> verkko; vector<bool> varit; ll n,m; cin >> n >> m; verkko.resize(n+1); varit.resize(n+1); for(int i = 1; i <= n; i++) { verkko[i] = vector<ll>(); } for(int i = 0; i < m; i++) { ll x,y; cin >> x >> y; verkko[x].push_back(y); verkko[y].push_back(x); } for(int i = 1; i <= n; i++) { ll c = 0; for(auto a : verkko[i]) { if (varit[a] == varit[i]) c++; else c--; } if (c > 0) varit[i] = !varit[i]; } for(int i = 1; i <= n; i++) { if (varit[i]) cout << "R "; else cout << "B "; } cout << endl; } }
Test details
Test 1
Verdict: ACCEPTED
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 R B B B B B R R R R B B B B R R R R R R B B B R R R R B B B R R R B R B R B B ... |
Test 2
Verdict: ACCEPTED
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 |
---|
R B R R B B B B B R B R B R 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 |
---|
R B R R R R B R R R R R R R R ... |