結果
問題 |
No.2042 RGB Caps
|
ユーザー |
![]() |
提出日時 | 2022-08-20 14:14:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 428 ms |
コンパイル使用メモリ | 47,176 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 07:02:50 |
合計ジャッジ時間 | 3,522 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 2 WA * 14 |
ソースコード
/* -*- coding: utf-8 -*- * * 2042.cc: No.2042 RGB Caps - yukicoder */ #include<cstdio> #include<algorithm> #include<utility> using namespace std; /* constant */ const int MAX_N = 100000; const char ccs[] = "RGB"; /* typedef */ typedef pair<int,int> 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); acs[i] = pii(ai, cmap[cis[0]]); } sort(acs, acs + k); fill(cs, cs + 3, 0); int l = 0; for (int i = 0; i < k; i++) { int ai = acs[i].first, ci = acs[i].second; int mi = (ai + 2) / 3; while (l < ai && cs[ci] < mi) s[l++] = ccs[ci], cs[ci]++; if (cs[ci] < cs[(ci + 1) % 3] || cs[ci] < cs[(ci + 2) % 3]) { puts("-1"); return 0; } } while (l < n) s[l++] = 'R'; puts(s); return 0; }