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 12:59:41
Task:Graph painting
Sender:Noname 01
Submission time:2016-05-28 12:59:41
Status:READY
Result:ACCEPTED

Show test data

Code

// NONAME-01

#include <bits/stdc++.h>


using namespace std;

int n, m;
vector< vector<int> > nxt;
vector <int> col;

void Load()
{
  cin >> n >> m;
  nxt.resize(n);
  int i;
  for (i = 0; i < n; i++) nxt.resize(0);
  for (i = 0; i < m; i++) {
	int a, b;
	cin >> a >> b;
	a--;
	b--;
	nxt[a].push_back(b);
	nxt[b].push_back(a);
  }
}

void Solve()
{
  int i, j;
  col.resize(n);
  col[0] = 0;
  int a, b;
  for (i = 1; i < n; i++) {
	  a = 0;
	  b = 0;
	  for (j = 0; j < (int)nxt[i].size();j++) {
		int k = nxt[i][j];
		if (k > i) continue;
		if (col[k] == 0) a++;
		else b++;
	  }
	  if (a > b) {
		col[i] = 1;
	  } else {
		col[i] = 0;
	  }
  }
  for (i = 0; i < n; i++) {
	if ( col[i] == 0) cout << "R ";
	else cout << "B ";
  }
  cout << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int nt, tt;
  cin >> nt;
  for (tt = 0; tt < nt; tt++) {
	Load();
	Solve();
  }
  return 0;
}