結果
| 問題 | No.2042 RGB Caps |
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-08-19 21:45:50 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 1,038 bytes |
| 記録 | |
| コンパイル時間 | 1,597 ms |
| コンパイル使用メモリ | 184,024 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-11 05:46:50 |
| 合計ジャッジ時間 | 2,510 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:35:13: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
35 | ok[x]= true;
| ^
main.cpp:29:13: note: 'x' was declared here
29 | int x;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,k;
cin >> n >> k;
vector<int> check(n,-1);
rep(i,k){
int a; char c;
cin >> a >> c;
a--;
if(c=='R') check[a] = 0;
if(c=='G') check[a] = 1;
if(c=='B') check[a] = 2;
}
string s, t = "RGB";
vector<bool> ok(3);
rep(i,n){
int x;
if(!(i%3)) rep(j,3) ok[j] = false;
if(check[i]>=0 && !ok[check[i]]) x = check[i];
else{
rep(j,3) if(!ok[j]) x = j;
}
ok[x]= true;
s += t[x];
}
cout << s << '\n';
return 0;
}
houren