結果
| 問題 | No.3211 NAND Oracle |
| コンテスト | |
| ユーザー |
rieaaddlreiuu
|
| 提出日時 | 2026-05-14 20:42:11 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 1,892 bytes |
| 記録 | |
| コンパイル時間 | 1,065 ms |
| コンパイル使用メモリ | 185,952 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-14 20:42:18 |
| 合計ジャッジ時間 | 4,097 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
33 | for (auto [i, j] : ops) {
| ^
main.cpp:51:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
51 | for (auto [i, j] : ops) {
| ^
main.cpp:67:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
67 | for (auto [i, j] : ops) {
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int Q, K;
cin >> Q >> K;
vector<pair<int, int>> ops;
auto no = [&]() {
cout << "No\n";
exit(0);
};
// K >= 5 なら任意の Q で可能
if (K >= 5) {
cout << "Yes\n";
if (Q >= 1) ops.push_back({1, 2}); // 3 = z = ~(x&y)
if (Q >= 2) ops.push_back({1, 2}); // 4 = z
if (Q >= 3) ops.push_back({3, 4}); // 5 = x&y
if (Q >= 4) ops.push_back({3, 5}); // 6 = 1
if (Q >= 5) ops.push_back({3, 5}); // 7 = 1
// 6,7 が定数 1 なので、以後 6 NAND 7 = 0 を出し続ける
while ((int)ops.size() < Q) {
ops.push_back({6, 7});
}
for (auto [i, j] : ops) {
cout << i << ' ' << j << '\n';
}
return 0;
}
// K = 4 なら Q <= 5 まで可能
if (K == 4) {
if (Q > 5) no();
cout << "Yes\n";
if (Q >= 1) ops.push_back({1, 2}); // z
if (Q >= 2) ops.push_back({1, 2}); // z
if (Q >= 3) ops.push_back({1, 2}); // z
if (Q >= 4) ops.push_back({3, 4}); // x&y
if (Q >= 5) ops.push_back({3, 4}); // x&y
for (auto [i, j] : ops) {
cout << i << ' ' << j << '\n';
}
return 0;
}
// K = 3 なら Q <= 3 まで可能
if (K == 3) {
if (Q > 3) no();
cout << "Yes\n";
if (Q >= 1) ops.push_back({1, 2}); // z
if (Q >= 2) ops.push_back({1, 2}); // z
if (Q >= 3) ops.push_back({3, 4}); // x&y
for (auto [i, j] : ops) {
cout << i << ' ' << j << '\n';
}
return 0;
}
// K = 2 なら Q = 1 のみ可能
if (K == 2) {
if (Q > 1) no();
cout << "Yes\n";
cout << "1 2\n";
return 0;
}
no();
}
rieaaddlreiuu