Task: | Graph painting |
Sender: | Oispa Kaljaa |
Submission time: | 2016-05-28 12:23:49 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.07 s | details |
#2 | WRONG ANSWER | 0.06 s | details |
#3 | WRONG ANSWER | 0.13 s | details |
Code
#include <bits/stdc++.h> using namespace std; int main(){ cin.sync_with_stdio(0); cin.tie(0); int tests; cin >> tests; while(tests--){ vector<int> v[101010]; int n, m; cin >> n >> m; bool ans[101010] = {0}; for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } vector<pair<int, int>> vs; for(int i = 1; i <= n; i++) vs.push_back({v[i].size(), i}); sort(vs.begin(), vs.end()); int cc = 0; for(int i = 0; i < n; i++){ int cur = vs[i].second; ans[cur] = 1; int ad = 0; for(auto f: v[cur]){ if(ans[f] == 0){ ad++; } else ad--; } cc+=ad; if(cc >= m/2) break; } for(int i = 1; i <= n; i++){ if(ans[i] == 1) cout << 'R' << " "; else cout << 'B' << " "; } cout << endl; } return 0; }
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 |
---|
R B B B B B B R R R B B B B B R B R R R R B R B B R R B B B B R R B R R B B B B ... |
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 |
---|
R R R R R R R R R B R R R R R ... |
Test 3
Verdict: WRONG ANSWER
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 R R R R R R R R R R R R R R ... |