結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-05 15:55:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,489 bytes |
| コンパイル時間 | 3,089 ms |
| コンパイル使用メモリ | 284,320 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-05 15:55:20 |
| 合計ジャッジ時間 | 7,217 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 3 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << ")", dbg_out(__VA_ARGS__)
#define int long long
const int MOD = 1e9 + 7;
const int INF = LLONG_MAX >> 1;
void solve() {
int n, k; cin >> n >> k;
pair<int, int> a[k];
for (int i = 0; i < k; i++) {
int x; cin >> x;
char c; cin >> c;
int y;
if (c == 'R') y = 0;
if (c == 'G') y = 1;
if (c == 'B') y = 2;
a[i] = {x, y};
}
sort(a, a + k);
vector<int> ans(n);
for (int i = 0; i < n; i++) {
ans[i] = i % 3;
}
for (int i = 0; i < k; i++) {
auto &[x, y] = a[i];
int k = (x - 1) / 3 * 3, ind = -1;
bool ok = false;
for (int l = k; l < min(k + 3, n); l++) {
if (ans[l] == y) {
ind = l;
ok = true;
break;
}
}
if (!ok) {
ans[x - 1] = y;
} else {
swap(ans[x - 1], ans[ind]);
}
}
for (int i = 0; i < n; i++) {
if (ans[i] == 0) cout << 'R';
if (ans[i] == 1) cout << 'G';
if (ans[i] == 2) cout << 'B';
}
cout << '\n';
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tc = 1;
// cin >> tc;
while (tc--) solve();
}
vjudge1