Task: | Graph painting |
Sender: | Team Purkka |
Submission time: | 2016-05-28 12:04:10 +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.19 s | details |
Code
#include <bits/stdc++.h> #define ll long long using namespace std; int main () { srand(time(0)); int t; cin>>t; for (int ca = 0; ca < t; ca++) { int n, m; cin>>n>>m; vector<pair<int, int>> v; for (int i = 0; i < m; i++) { int a, b; cin>>a>>b; v.push_back({a, b}); } while (true) { int c[n + 1]; for (int i = 1; i <= n; i++) c[i] = rand() % 2; int s = 0; for (int i = 0; i < m; i++) { if (c[v[i].first] != c[v[i].second]) s++; } if (s >= m / 2) { for (int i = 1; i <= n; i++) { if (c[i]) cout<<"B "; else cout<<"R "; } cout<<endl; break; } } } }
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 R B B R R R B B R R R B B R R R R R B R R B B R B B R R B B B B B B R R R B R ... |
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 R B B R B B B B R B B B R R ... |
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 B R B R R B R B R R R ... |