/* -*- coding: utf-8 -*- * * 2042.cc: No.2042 RGB Caps - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const char ccs[] = "RGB"; /* typedef */ typedef pair pii; /* global variables */ int cmap[128], cs[3]; pii acs[MAX_N]; char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { for (int i = 0; ccs[i]; i++) cmap[ccs[i]] = i; int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < k; i++) { int ai; char cis[4]; scanf("%d%s", &ai, cis), ai--; acs[i] = pii(ai, cmap[cis[0]]); } sort(acs, acs + k); fill(cs, cs + 3, 0); for (int i = 0, j = 0; i < n; i++) { int mc = i / 3; if (j < k && acs[j].first == i) { int cj = acs[j++].second; for (int d = 0; d < 3; d++) { int cd = (cj + d) % 3; if (cs[cd] == mc) { s[i] = ccs[cd]; cs[cd]++; break; } } } else { for (int cd = 0; cd < 3; cd++) if (cs[cd] == mc) { s[i] = ccs[cd]; cs[cd]++; break; } } } puts(s); return 0; }