Task: | Graph painting |
Sender: | Barely Div 1 |
Submission time: | 2016-05-28 12:21:59 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.19 s | details |
Code
#include <iostream> #include <string> #include <set> #include <vector> #include <utility> using namespace std; typedef int64_t LL; void solve(){ int nVertices, nEdges; cin >> nVertices >> nEdges; vector<pair<int,int> > edges; for(int i = 0; i < nEdges; i++){ int u,v; cin >> u >> v; u--; v--; edges.push_back({u,v}); } vector<int> colors(nVertices); while(true){ for(int i = 0; i < nVertices; i++){ colors[i] = rand() % 2; } int good = 0; for(auto edge : edges){ if(colors[edge.first] != colors[edge.second]) good++; } if(good >= nEdges/2){ for(int i = 0; i < nVertices; i++){ if(colors[i] == 1) cout << "R "; else cout << "B "; } cout << "\n"; return; } } } int main(){ srand(345348345); LL t; cin >> t; while(t--) solve(); }
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 R B R R R B R R B R B R B R R R B R B R R B B B B R R B B B B R R R B 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 |
---|
B R B R B R R R B R R B R B 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 R R R R R B B R R R R B R B ... |