Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 15:29:13
2016-05-28 15:27:26
Task:Graph painting
Sender:zah
Submission time:2016-05-28 15:29:13
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

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";
    }

}