結果
| 問題 |
No.2307 [Cherry 5 th Tune *] Cool 46
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-19 21:43:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 407 ms / 2,000 ms |
| コード長 | 1,345 bytes |
| コンパイル時間 | 1,977 ms |
| コンパイル使用メモリ | 205,660 KB |
| 最終ジャッジ日時 | 2025-02-13 01:38:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
コンパイルメッセージ
main.cpp: In function ‘bool isOK(Vp&)’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf(" %d %d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf(" %d", &a);
| ~~~~~^~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf(" %d", &a);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using Vp = std::vector<pair<int, int>> ;
bool isOK(Vp& ret) {
int N, M;
scanf(" %d %d", &N, &M);
vector<int> A(N), B(M);
unordered_set<int> sta, stb;
for (auto& a : A) {
scanf(" %d", &a);
sta.insert(a);
}
for (auto& a : B) {
scanf(" %d", &a);
stb.insert(a);
}
// sort(A.begin(), A.end());
// sort(B.begin(), B.end());
vector<int> aon, bon, ab;
for (auto a : A) {
if (stb.find(a) != stb.end()) {
ab.push_back(a);
} else {
aon.push_back(a);
}
}
for (auto a : B) {
if (sta.find(a) == sta.end()) {
bon.push_back(a);
}
}
if (ab.empty() && N && M) {
return false;
}
if (N + M == max(N, M)) {
for (auto a : A) {
ret.emplace_back(1, a);
}
for (auto a : B) {
ret.emplace_back(0, a);
}
return true;
}
for (auto a : aon) {
ret.emplace_back(1, a);
}
ret.emplace_back(1, ab[0]);
ret.emplace_back(0, ab[0]);
for (auto a : bon) {
ret.emplace_back(0, a);
}
for (int i = 1; i < ab.size(); i ++) {
int id = (i & 1) ^ 1;
ret.emplace_back(id, ab[i]);
ret.emplace_back(id ^ 1, ab[i]);
}
return true;
}
void solve() {
Vp ret;
if (isOK(ret)) {
puts("Yes");
for (auto [a, b] : ret) {
cout << (a ? "Red" : "Blue") << " " << b << endl;
}
} else {
puts("No");
}
}
int main () {
int n;
cin >> n;
while (n --) {
solve();
}
}