結果
問題 | No.726 Tree Game |
ユーザー | tkmst201 |
提出日時 | 2021-02-12 15:37:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,377 bytes |
コンパイル時間 | 2,099 ms |
コンパイル使用メモリ | 199,820 KB |
最終ジャッジ日時 | 2025-01-18 17:49:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#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"); }