結果
問題 |
No.3211 NAND Oracle
|
ユーザー |
![]() |
提出日時 | 2025-07-25 21:41:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,651 bytes |
コンパイル時間 | 3,373 ms |
コンパイル使用メモリ | 292,804 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 21:41:14 |
合計ジャッジ時間 | 7,570 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 20 WA * 8 |
ソースコード
#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(1, 2); OUT(1, 2); for (int _ : Rep(0, Q - 4)) { OUT(3, 4); } } else { OUT("No"); } return; } vector<pair<int, int>> ops; ops.reserve(Q); Fix([&](auto self, int n) -> void { 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) { OUT("Yes"); for (auto [i, j] : ops) { OUT(i + 1, j + 1); } exit(0); } 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); 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