結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
bit_kyopro
|
| 提出日時 | 2022-08-19 22:03:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 1,088 bytes |
| コンパイル時間 | 866 ms |
| コンパイル使用メモリ | 80,352 KB |
| 最終ジャッジ日時 | 2025-01-31 01:08:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
int n; cin >> n;
int m; cin >> m;
string v = string(n + 2, '.');
string ans = string(n + 2, '.');
for (int i=0; i<m; i++) {
int a;
cin >> a;
a--;
cin >> v[a];
}
for (int i=0; i<n; i+=3) {
set<char> st;
for (int j=0; j<3; j++) {
if (v[i + j] == '.') continue;
if (!st.count(v[i + j])) {
ans[i + j] = v[i + j];
}
st.insert(v[i + j]);
}
for (int j=0; j<3; j++) {
if (ans[i + j] != '.') continue;
if (!st.count('R')) {
ans[i + j] = 'R';
st.insert('R');
}
else if (!st.count('G')) {
ans[i + j] = 'G';
st.insert('G');
}
else {
ans[i + j] = 'B';
st.insert('B');
}
}
}
cout << ans.substr(0, n) << endl;
}
bit_kyopro