結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー hiro71687khiro71687k
提出日時 2023-05-21 00:52:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,507 bytes
コンパイル時間 4,375 ms
コンパイル使用メモリ 212,804 KB
実行使用メモリ 30,196 KB
最終ジャッジ日時 2023-08-23 10:49:17
合計ジャッジ時間 38,814 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 484 ms
20,044 KB
testcase_33 AC 634 ms
30,196 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 352 ms
4,376 KB
testcase_39 AC 488 ms
4,380 KB
testcase_40 AC 383 ms
4,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 477 ms
18,732 KB
testcase_45 AC 475 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=300000000;
ll mod=998244353;
int main(){
    ll t;
    cin >> t;
    for (ll o = 0; o < t; o++)
    {
        ll n,m;
        cin >> n >> m;
        vector<ll>a(n),b(m);
        map<ll,ll>memo;
        for (ll i = 0; i < n; i++)
        {
            cin >> a[i];
            memo[a[i]]+=1;
        }
        map<ll,ll>mm;
        vector<ll>aa(n,0),bb(m,0);
        ll now=0;
        for (ll i = 0; i < m; i++)
        {
            cin >> b[i];
            if (memo[b[i]]>=1)
            {
                now++;
                bb.push_back(i);
                memo[b[i]]--;
                mm[b[i]]+=1;
                bb[i]=1;
            }
        }
        if (n==0)
        {
            cout << "Yes" << endl;
            for (ll i = 0; i < m; i++)
            {
                cout << "Blue " << b[i] << endl;
            }
            continue;
        }
        if (m==0)
        {
            cout << "Yes" << endl;
            for (ll i = 0; i < n; i++)
            {
                cout << "Red " << a[i] << endl;
            }
            continue;
        }
        
        for (ll i = 0; i < n; i++)
        {
            if (mm[a[i]]>=1)
            {
                mm[a[i]]--;
                aa[i]=1;
            }
        }
        if (now==0)
        {
            cout << "No" << endl;
            continue;
        }
        if (now%2)
        {
            cout << "Yes" << endl;
            for (ll i = 0; i < n; i++)
            {
                if (aa[i]==0)
                {
                    cout << "Red " << a[i] << endl;
                }
            }
            ll x=0;
            for (ll i = 0; i < n; i++)
            {
                if (aa[i]==1)
                {
                    if (x%2==0)
                    {
                        cout << "Red " << a[i]<< endl;
                        cout << "Blue " << a[i] << endl;
                    }else{
                        cout << "Blue " << a[i] << endl;
                        cout << "Red " << a[i]<< endl;
                    }
                }
            }
            for (ll i = 0; i < m; i++)
            {
                if (bb[i]==0)
                {
                    cout << "Blue " << b[i] << endl;
                }
            }
        }else{
            cout << "Yes" << endl;
            ll saisyo=inf;
            for (ll i = 0; i < n; i++)
            {
                if (aa[i]==0)
                {
                    cout << "Red " << a[i] << endl;
                }else{
                    saisyo=min(saisyo,i);
                }
            }
            cout << "Red " << a[saisyo] << endl;
            cout << "Blue " << a[saisyo] << endl;
            ll x=1;
            for (ll i = 0; i < m; i++)
            {
                if (bb[i]==0)
                {
                    cout << "Blue " << b[i] << endl;
                }
            }
            for (ll i = 0; i < n; i++)
            {
                if (aa[i]==1&&i!=saisyo)
                {
                    if (x%2==0)
                    {
                        cout << "Red " << a[i]<< endl;
                        cout << "Blue " << a[i] << endl;
                    }else{
                        cout << "Blue " << a[i] << endl;
                        cout << "Red " << a[i]<< endl;
                    }
                }
            }
        }
    }
    
}
0