結果
| 問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-06-04 15:24:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 2,000 ms |
| コード長 | 1,635 bytes |
| コンパイル時間 | 888 ms |
| コンパイル使用メモリ | 63,584 KB |
| 実行使用メモリ | 6,808 KB |
| 最終ジャッジ日時 | 2024-12-29 03:34:33 |
| 合計ジャッジ時間 | 25,773 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:79:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
79 | for (auto [c, e]: ans)
| ^
ソースコード
/* -*- coding: utf-8 -*-
*
* 2307.cc: No.2307 [Cherry 5 th Tune *] Cool 46 - yukicoder
*/
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int MAX_M = 200000;
enum { R, B };
const char css[2][8] = {"Red", "Blue"};
/* typedef */
typedef queue<int> qi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
/* global variables */
int as[MAX_N], bs[MAX_M];
/* subroutines */
/* main */
int main() {
int tn;
scanf("%d", &tn);
while (tn--) {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = 0; i < m; i++) scanf("%d", bs + i);
sort(as, as + n);
sort(bs, bs + m);
qi rv, bv, ev;
int ai = 0, bi = 0;
while (ai < n && bi < m) {
if (as[ai] < bs[bi]) rv.push(as[ai++]);
else if (as[ai] > bs[bi]) bv.push(bs[bi++]);
else ev.push(as[ai++]), bi++;
}
while (ai < n) rv.push(as[ai++]);
while (bi < m) bv.push(bs[bi++]);
if (! rv.empty() && ! bv.empty() && ev.empty()) {
puts("No"); continue;
}
vpii ans;
int c = (! rv.empty()) ? R : B;
while (! rv.empty() || ! bv.empty() || ! ev.empty()) {
while (c == R && ! rv.empty())
ans.push_back({R, rv.front()}), rv.pop();
while (c == B && ! bv.empty())
ans.push_back({B, bv.front()}), bv.pop();
if (! ev.empty()) {
int e = ev.front(); ev.pop();
ans.push_back({c, e});
c ^= 1;
ans.push_back({c, e});
}
}
puts("Yes");
for (auto [c, e]: ans)
printf("%s %d\n", css[c], e);
}
return 0;
}
tnakao0123