結果
問題 |
No.8 N言っちゃダメゲーム
|
ユーザー |
![]() |
提出日時 | 2020-03-30 13:44:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,166 bytes |
コンパイル時間 | 668 ms |
コンパイル使用メモリ | 48,748 KB |
最終ジャッジ日時 | 2025-01-09 11:02:49 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d", &p); | ~~~~~^~~~~~~~~~ main.cpp:38:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d %d", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
/** * @brief ラムダ式の再帰 * @author えびちゃん */ #ifndef H_make_fix_point #define H_make_fix_point #include <utility> template <typename Fn> class fix_point: Fn { public: explicit constexpr fix_point(Fn&& f) noexcept: Fn(std::forward<Fn>(f)) {} template <typename... Args> constexpr decltype(auto) operator ()(Args&&... args) const { return Fn::operator ()(*this, std::forward<Args>(args)...); } }; template <typename Fn> static inline constexpr decltype(auto) make_fix_point(Fn&& f) noexcept { return fix_point<Fn>{std::forward<Fn>(f)}; } #endif /* !defined(H_make_fix_point) */ #include <cstdio> #include <vector> int main() { int p; scanf("%d", &p); while (p--) { int n, k; scanf("%d %d", &n, &k); std::vector<int> memo(n, 0); memo[0] = -1; int res = make_fix_point([&](auto dfs, int m) -> int { auto& res = memo[m]; if (res != 0) return res; res = -1; for (int i = 1; i <= k; ++i) { if (m-i < 0) break; if (dfs(m-i) == -1) { res = 1; break; } } return res; })(n-1); puts((res == 1)? "Win": "Lose"); } }