結果

問題 No.2148 ひとりUNO
ユーザー hotman78hotman78
提出日時 2022-12-05 11:44:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,435 bytes
コンパイル時間 2,876 ms
コンパイル使用メモリ 218,460 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 13:58:59
合計ジャッジ時間 4,984 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 7 ms
6,940 KB
testcase_02 AC 7 ms
6,940 KB
testcase_03 AC 7 ms
6,944 KB
testcase_04 AC 6 ms
6,940 KB
testcase_05 AC 7 ms
6,940 KB
testcase_06 AC 7 ms
6,940 KB
testcase_07 AC 7 ms
6,940 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 6 ms
6,940 KB
testcase_15 AC 7 ms
6,944 KB
testcase_16 AC 52 ms
6,940 KB
testcase_17 AC 52 ms
6,944 KB
testcase_18 AC 52 ms
6,944 KB
testcase_19 AC 52 ms
6,944 KB
testcase_20 AC 49 ms
6,944 KB
testcase_21 AC 50 ms
6,940 KB
testcase_22 AC 51 ms
6,944 KB
testcase_23 AC 52 ms
6,940 KB
testcase_24 AC 50 ms
6,944 KB
testcase_25 AC 49 ms
6,940 KB
testcase_26 AC 20 ms
6,940 KB
testcase_27 AC 20 ms
6,944 KB
testcase_28 AC 19 ms
6,944 KB
testcase_29 AC 21 ms
6,944 KB
testcase_30 AC 19 ms
6,940 KB
testcase_31 AC 19 ms
6,944 KB
testcase_32 AC 20 ms
6,944 KB
testcase_33 AC 20 ms
6,940 KB
testcase_34 AC 20 ms
6,940 KB
testcase_35 AC 19 ms
6,944 KB
testcase_36 AC 20 ms
6,940 KB
testcase_37 AC 19 ms
6,944 KB
testcase_38 AC 19 ms
6,940 KB
testcase_39 AC 2 ms
6,940 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);
    set<pair<lint,char>>ss;
    rep(i,n){
        string tmp;
        char c;
        lint j;
        cin>>tmp>>j;
        c=tmp[0];
        j--;
        if(ss.count(make_pair(j,c))){
            assert(0);
        }
        ss.emplace(j,c);
        assert(0<=j&j<n);
        s[j]+=c;
        string t="BGR";
        rep(k,3){
            if(t[k]==c){
                cnt[k]++;
            }
        }
    }
    assert(cnt[0]+cnt[1]+cnt[2]==n);
    rep(i,n)sort(all(s[i]));
    sort(all(s));
    //rep(i,n)cerr<<s[i]<<endl;
    //cerr<<"end"<<endl;
    lint p=count(all(s),"GR");
    lint q=count(all(s),"BR");
    lint r=count(all(s),"BG");
    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(count(all(s),"BGR")>=2){
        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