結果
問題 | No.726 Tree Game |
ユーザー | tkmst201 |
提出日時 | 2021-02-12 15:37:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,377 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 207,388 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-26 14:32:17 |
合計ジャッジ時間 | 3,356 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,384 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,384 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,384 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 2 ms
4,384 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair<int, int>; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int Y, X; cin >> Y >> X; auto is_prime = [](int i) { if (i <= 1) return false; for (int j = 2; j * j <= i; ++j) if (i % j == 0) return false; return true; }; auto nex_prime = [&](int i) { while (!is_prime(i)) ++i; return i; }; const int ey1 = nex_prime(Y), ey2 = nex_prime(ey1 + 1); const int ex1 = nex_prime(X), ex2 = nex_prime(ex1 + 1); map<pii, bool> dp; auto dfs = [&](auto self, int y, int x) -> bool { const pii cur = {y, x}; if (y == ey1 || y == ey2 || x == ex1 || x == ex2) return false; if (dp.count(cur)) return dp[cur]; if (self(self, y + 1, x) || self(self, y, x + 1)) return dp[cur] = false; return dp[cur] = true; }; if (dfs(dfs, Y + 1, X) || dfs(dfs, Y, X + 1)) puts("First"); else puts("Second"); }