Task: | Graph painting |
Sender: | zah |
Submission time: | 2016-05-28 15:29:13 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:57:26: warning: unused variable 'lol' [-Wunused-variable] while(y<m/2) int lol=0; ^
Code
#include<iostream> #include <vector> using namespace std; int main(){ int t; cin >> t; for(int p=0; p<t; ++p){ int n, m; cin>> n >> m; vector<int> v[n+1]; for(int i=0; i<m; ++i){ int a, b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } char ss[n+1]; for( int i=0; i<=n; ++i) ss[i]='B'; int z[100001]={}; int e[100001]={}; vector<int> q; q.push_back(1); int y=0; char a[100001]; z[1]=1; e[1]=1; for(unsigned int i=0; i<q.size(); ++i){ for (unsigned int j=0; j<v[q[i]].size(); ++j){ int u=v[q[i]][j]; if (z[u]){ if (ss[u]==a[q[i]]){ ++y; } } else{ z[u]=1; if(e[q[i]]==1){ e[u]=2; ss[u]='R'; a[u]='B'; } else{ e[u]=2; a[u]='R'; } } } if(y>=m/2){ break; } } while(y<m/2) int lol=0; for (int i=1; i<=n; ++i){ cout << ss[i] << " "; } cout << "\n"; } }
Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
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 |
---|
(empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
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 |
---|
(empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
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 |
---|
(empty) |