結果

問題 No.2148 ひとりUNO
ユーザー hotman78hotman78
提出日時 2022-12-05 10:13:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 3,135 ms
コンパイル使用メモリ 211,392 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 12:59:41
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 35 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 35 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 15 ms
5,376 KB
testcase_27 AC 15 ms
5,376 KB
testcase_28 AC 14 ms
5,376 KB
testcase_29 AC 15 ms
5,376 KB
testcase_30 AC 14 ms
5,376 KB
testcase_31 AC 15 ms
5,376 KB
testcase_32 AC 14 ms
5,376 KB
testcase_33 AC 15 ms
5,376 KB
testcase_34 AC 14 ms
5,376 KB
testcase_35 AC 15 ms
5,376 KB
testcase_36 AC 15 ms
5,376 KB
testcase_37 AC 14 ms
5,376 KB
testcase_38 AC 15 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using lint=long long;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(n) (n).begin(),(n).end()

void solve(){
    lint n;
    cin>>n;
    vector<string>s(n);
    vector<lint>cnt(3);
    rep(i,n){
        char c;
        lint j;
        cin>>c>>j;
        j--;
        s[j]+=c;
        string t="BRG";
        rep(k,3){
            if(t[k]==c){
                cnt[k]++;
            }
        }
    }
    rep(i,n)sort(all(s[i]));
    sort(all(s));
    lint p=count(all(s),"GR");
    lint q=count(all(s),"BG");
    lint r=count(all(s),"BR");
    if((p&&q)||(q&&r)||(r&&p)){
        cout<<"YES"<<endl;
    }else if((p||q||r)&&count(all(s),"BGR")){
        cout<<"YES"<<endl;
    }else if(count(all(s),"BGR")&&*min_element(all(cnt))==1){
        cout<<"YES"<<endl;
    }else if((p&&cnt[0]==0)||(q&&cnt[1]==0)||(r&&cnt[2]==0)){
        cout<<"YES"<<endl;
    }else if((cnt[0]==n)||(cnt[1]==n)||(cnt[2]==n)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}
int main(){
    int t;
    cin>>t;
    while(t--)solve();
}
0