結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー yansi819yansi819
提出日時 2024-04-08 18:16:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 598 ms / 2,000 ms
コード長 1,312 bytes
コンパイル時間 6,333 ms
コンパイル使用メモリ 271,672 KB
実行使用メモリ 22,400 KB
最終ジャッジ日時 2024-04-08 18:17:30
合計ジャッジ時間 51,840 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 311 ms
6,676 KB
testcase_03 AC 284 ms
6,676 KB
testcase_04 AC 309 ms
6,676 KB
testcase_05 AC 273 ms
6,676 KB
testcase_06 AC 322 ms
6,676 KB
testcase_07 AC 248 ms
6,676 KB
testcase_08 AC 372 ms
10,240 KB
testcase_09 AC 371 ms
11,392 KB
testcase_10 AC 333 ms
11,392 KB
testcase_11 AC 420 ms
9,600 KB
testcase_12 AC 325 ms
10,112 KB
testcase_13 AC 490 ms
11,520 KB
testcase_14 AC 397 ms
12,160 KB
testcase_15 AC 291 ms
8,576 KB
testcase_16 AC 421 ms
8,064 KB
testcase_17 AC 356 ms
10,624 KB
testcase_18 AC 571 ms
22,400 KB
testcase_19 AC 548 ms
18,560 KB
testcase_20 AC 555 ms
22,272 KB
testcase_21 AC 552 ms
21,632 KB
testcase_22 AC 534 ms
22,400 KB
testcase_23 AC 584 ms
21,888 KB
testcase_24 AC 538 ms
20,608 KB
testcase_25 AC 535 ms
21,504 KB
testcase_26 AC 573 ms
22,400 KB
testcase_27 AC 568 ms
21,760 KB
testcase_28 AC 557 ms
21,760 KB
testcase_29 AC 543 ms
22,144 KB
testcase_30 AC 518 ms
19,200 KB
testcase_31 AC 598 ms
22,400 KB
testcase_32 AC 573 ms
22,400 KB
testcase_33 AC 572 ms
22,400 KB
testcase_34 AC 558 ms
21,376 KB
testcase_35 AC 559 ms
19,072 KB
testcase_36 AC 572 ms
20,992 KB
testcase_37 AC 533 ms
21,760 KB
testcase_38 AC 370 ms
6,676 KB
testcase_39 AC 523 ms
6,676 KB
testcase_40 AC 406 ms
6,676 KB
testcase_41 AC 429 ms
6,676 KB
testcase_42 AC 516 ms
17,664 KB
testcase_43 AC 515 ms
17,664 KB
testcase_44 AC 560 ms
22,400 KB
testcase_45 AC 587 ms
22,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

void solve() {
  int N, M; cin >> N >> M;
  set<int> r, b, c, d, e;
  for (int i = 1; i <= N; i++) {
    int x; cin >> x;
    r.insert(x);
  }
  for (int i = 1; i <= M; i++) {
    int x; cin >> x;
    b.insert(x);
  }
  set_intersection(r.begin(), r.end(), b.begin(), b.end(), inserter(c, c.end()));
  set_difference(r.begin(), r.end(), c.begin(), c.end(), inserter(d, d.end()));
  set_difference(b.begin(), b.end(), c.begin(), c.end(), inserter(e, e.end()));
  if (c.size() == 0 && (d.size() > 0 && e.size() > 0)) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  for (auto x: d) {
    cout << "Red " << x << endl;
  }
  if (c.size() > 0) {
    cout << "Red " << *c.begin() << endl;
    cout << "Blue " << *c.begin() << endl;
    c.erase(*c.begin());
  }
  for (auto x: e) {
    cout << "Blue " << x << endl;
  }
  int pos = 0;
  for (auto x: c) {
    if (pos % 2 == 0) {
      cout << "Blue " << x << endl;
      cout << "Red " << x << endl;
    } else {
      cout << "Red " << x << endl;
      cout << "Blue " << x << endl;
    }
    pos++;
  }
}

int main() {
  int T; cin >> T;
  while (T--) solve();
  return 0;
}
0