結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー kotatsugamekotatsugame
提出日時 2023-05-19 21:26:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 79,916 KB
実行使用メモリ 13,300 KB
最終ジャッジ日時 2023-08-23 02:26:56
合計ジャッジ時間 30,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,936 KB
testcase_01 AC 1 ms
5,008 KB
testcase_02 AC 109 ms
5,004 KB
testcase_03 AC 117 ms
4,940 KB
testcase_04 AC 112 ms
5,000 KB
testcase_05 AC 111 ms
5,004 KB
testcase_06 AC 115 ms
4,936 KB
testcase_07 AC 112 ms
5,000 KB
testcase_08 AC 153 ms
6,552 KB
testcase_09 AC 144 ms
6,176 KB
testcase_10 AC 129 ms
5,316 KB
testcase_11 AC 154 ms
5,620 KB
testcase_12 AC 142 ms
7,312 KB
testcase_13 AC 144 ms
4,940 KB
testcase_14 AC 160 ms
7,908 KB
testcase_15 AC 122 ms
5,008 KB
testcase_16 AC 134 ms
4,940 KB
testcase_17 AC 135 ms
6,220 KB
testcase_18 AC 208 ms
10,020 KB
testcase_19 AC 188 ms
7,984 KB
testcase_20 AC 141 ms
5,176 KB
testcase_21 AC 140 ms
5,348 KB
testcase_22 AC 204 ms
10,980 KB
testcase_23 AC 140 ms
5,352 KB
testcase_24 AC 226 ms
10,560 KB
testcase_25 AC 216 ms
10,352 KB
testcase_26 AC 144 ms
5,356 KB
testcase_27 AC 222 ms
11,044 KB
testcase_28 AC 153 ms
5,960 KB
testcase_29 AC 160 ms
6,588 KB
testcase_30 AC 212 ms
9,716 KB
testcase_31 AC 139 ms
5,188 KB
testcase_32 AC 139 ms
5,192 KB
testcase_33 AC 234 ms
12,776 KB
testcase_34 AC 239 ms
12,432 KB
testcase_35 AC 196 ms
8,512 KB
testcase_36 AC 151 ms
6,064 KB
testcase_37 AC 199 ms
9,540 KB
testcase_38 AC 225 ms
4,384 KB
testcase_39 AC 279 ms
4,940 KB
testcase_40 AC 117 ms
4,384 KB
testcase_41 AC 126 ms
5,004 KB
testcase_42 AC 192 ms
8,292 KB
testcase_43 AC 192 ms
8,240 KB
testcase_44 AC 240 ms
13,300 KB
testcase_45 AC 101 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<vector>
using namespace std;
int N,M;
vector<int>A,B,AB;
int main()
{
	int T;cin>>T;
	for(;T--;)
	{
		A.clear();
		B.clear();
		AB.clear();
		set<int>S;
		int N,M;cin>>N>>M;
		for(int i=0;i<N;i++)
		{
			int a;cin>>a;
			S.insert(a);
		}
		for(int i=0;i<M;i++)
		{
			int b;cin>>b;
			if(S.find(b)!=S.end())
			{
				S.erase(b);
				AB.push_back(b);
			}
			else B.push_back(b);
		}
		for(int a:S)A.push_back(a);
		if(AB.empty())
		{
			if(!A.empty()&&!B.empty())cout<<"No\n";
			else
			{
				cout<<"Yes\n";
				for(int a:A)cout<<"Red "<<a<<"\n";
				for(int b:B)cout<<"Blue "<<b<<"\n";
			}
		}
		else
		{
			cout<<"Yes\n";
			for(int a:A)cout<<"Red "<<a<<"\n";
			cout<<"Red "<<AB.back()<<"\n";
			cout<<"Blue "<<AB.back()<<"\n";
			for(int b:B)cout<<"Blue "<<b<<"\n";
			AB.pop_back();
			for(int i=0;i<AB.size();i++)
			{
				if(i%2==0)
				{
					cout<<"Blue "<<AB[i]<<"\n";
					cout<<"Red "<<AB[i]<<"\n";
				}
				else
				{
					cout<<"Red "<<AB[i]<<"\n";
					cout<<"Blue "<<AB[i]<<"\n";
				}
			}
		}
	}
}
0