結果
| 問題 |
No.3211 NAND Oracle
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2025-07-25 23:03:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 2,757 bytes |
| コンパイル時間 | 3,434 ms |
| コンパイル使用メモリ | 294,928 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-25 23:03:59 |
| 合計ジャッジ時間 | 6,275 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
void Solve() {
int Q, K;
IN(Q, K);
if (Q >= 6) {
if (K >= 5) {
OUT("Yes");
OUT(1, 2);
OUT(1, 2);
OUT(3, 4);
OUT(3, 5);
OUT(3, 5);
for (int _ : Rep(0, Q - 5)) {
OUT(6, 7);
}
} else {
OUT("No");
}
return;
}
vector<pair<int, int>> ops;
ops.reserve(Q);
vector<pair<int, int>> ans;
Fix([&](auto self, int n) -> void {
if (Sz(ans)) {
return;
}
if (Sz(ops) == Q) {
bool ok = true;
for (int a0 : Rep(0, 2)) {
for (int a1 : Rep(0, 2)) {
vector<int> a{a0, a1};
a.reserve(Q + 2);
for (auto [i, j] : ops) {
a.push_back((a[i] & a[j]) ^ 1);
}
ok &= int(ranges::count(a, 1)) <= K;
}
}
if (ok) {
ans = ops;
}
return;
}
for (int i : Rep(0, n)) {
for (int j : Rep(i + 1, n)) {
ops.emplace_back(i, j);
self(n + 1);
ops.pop_back();
}
}
})(2);
if (Sz(ans)) {
OUT("Yes");
for (auto [i, j] : ans) {
OUT(i + 1, j + 1);
}
} else {
OUT("No");
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
Solve();
}
#elif __INCLUDE_LEVEL__ == 1
#include <bits/stdc++.h>
template <class F>
class Fix {
public:
explicit Fix(F f) : f_(std::move(f)) {}
template <class... Ts>
decltype(auto) operator()(Ts&&... xs) {
return f_(std::ref(*this), std::forward<Ts>(xs)...);
}
template <class... Ts>
decltype(auto) operator()(Ts&&... xs) const {
return f_(std::ref(*this), std::forward<Ts>(xs)...);
}
private:
F f_;
};
template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>;
namespace std {
istream& operator>>(istream& is, MyRange auto&& r) {
for (auto&& e : r) is >> e;
return is;
}
istream& operator>>(istream& is, MyTuple auto&& t) {
apply([&](auto&... xs) { (is >> ... >> xs); }, t);
return is;
}
ostream& operator<<(ostream& os, MyRange auto&& r) {
auto sep = "";
for (auto&& e : r) os << exchange(sep, " ") << e;
return os;
}
ostream& operator<<(ostream& os, MyTuple auto&& t) {
auto sep = "";
apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);
return os;
}
} // namespace std
using namespace std;
#define _ _ [[maybe_unused]]
#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)
#define Sz(r) int(size(r))
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')
#endif // __INCLUDE_LEVEL__ == 1
risujiroh