結果

問題 No.2042 RGB Caps
ユーザー hourenhouren
提出日時 2022-08-19 21:45:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 170,904 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 20:32:19
合計ジャッジ時間 2,353 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,948 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 9 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 12 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 14 ms
6,940 KB
testcase_13 AC 14 ms
6,940 KB
testcase_14 AC 14 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 5 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |             ^

ソースコード

diff #

#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;
}
0