結果
問題 | No.2042 RGB Caps |
ユーザー | houren |
提出日時 | 2022-08-19 21:45:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,038 bytes |
コンパイル時間 | 1,644 ms |
コンパイル使用メモリ | 172,148 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-16 01:54:53 |
合計ジャッジ時間 | 2,772 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:65, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/queue:61, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:86, from main.cpp:1: In member function 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>]', inlined from 'int main()' at main.cpp:35:13: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_bvector.h:1036:23: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized] 1036 | { return begin()[__n]; } | ~~~~~~~^ main.cpp: In function 'int main()': 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; }