結果

問題 No.2042 RGB Caps
ユーザー hiro71687khiro71687k
提出日時 2023-04-15 16:56:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,906 bytes
コンパイル時間 4,503 ms
コンパイル使用メモリ 258,572 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 10:31:53
合計ジャッジ時間 6,221 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 46 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 48 ms
5,376 KB
testcase_13 AC 48 ms
5,376 KB
testcase_14 AC 48 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 12 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:76:13: warning: 'r' may be used uninitialized [-Wmaybe-uninitialized]
   76 |             if (r>0)
      |             ^~
main.cpp:26:8: note: 'r' was declared here
   26 |     ll r,b,g;
      |        ^
main.cpp:54:17: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   54 |                 if (b==1)
      |                 ^~
main.cpp:26:10: note: 'b' was declared here
   26 |     ll r,b,g;
      |          ^
main.cpp:80:19: warning: 'g' may be used uninitialized [-Wmaybe-uninitialized]
   80 |             }else if (g>0)
      |                   ^~
main.cpp:26:12: note: 'g' was declared here
   26 |     ll r,b,g;
      |            ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144499999999994;
ll mod=1000000007;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,char>>p(k);
    for (ll i = 0; i < k; i++)
    {
        cin >> p[i].first >> p[i].second;
        p[i].first--;
    }
    sort(p.begin(),p.end());
    string s;
    for (ll i = 0; i < n; i++)
    {
        s.push_back('N');
    }
    ll now=0;
    ll r,b,g;
    for (ll i = 0; i < n; i++)
    {
        if (i%3==0)
        {
            r=1,b=1,g=1;
        }
        if (p[now].first==i)
        {
            if (p[now].second=='R')
            {
                if (r==1)
                {
                    s[i]='R';
                    r=0;
                    now+=1;
                    continue;
                }
            }else if (p[now].second=='G')
            {
                if (g==1)
                {
                    s[i]='G';
                    g=0;
                    now+=1;
                    continue;
                }
            }else{
                if (b==1)
                {
                    s[i]='B';
                    b=0;
                    now+=1;
                    continue;
                }
            }
            if (r>0)
            {
                s[i]='R';
                r=0;
            }else if (g>0)
            {
                s[i]='G';
                g=0;
            }else{
                s[i]='B';
                b=0;
            }
            now+=1;
        }else{
            if (r>0)
            {
                s[i]='R';
                r=0;
            }else if (g>0)
            {
                s[i]='G';
                g=0;
            }else{
                s[i]='B';
                b=0;
            }
        }
    }
    cout << s << endl;
}
0