結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
treeone
|
| 提出日時 | 2018-03-30 00:06:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,361 bytes |
| コンパイル時間 | 1,835 ms |
| コンパイル使用メモリ | 167,608 KB |
| 実行使用メモリ | 25,052 KB |
| 最終ジャッジ日時 | 2024-06-26 00:11:24 |
| 合計ジャッジ時間 | 7,980 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 24 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
const int MAX_N = 1010;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
void sieve(int n){
int p = 0;
for(int i = 0; i <= n; i++) is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for(int i = 2; i <= n; i++){
if(is_prime[i]){
prime[p++] = i;
for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
}
}
}
int h, w;
int dp[1010][1010];
int dy[2] = {1, 0};
int dx[2] = {0, 1};
bool calc(int y, int x){
if(dp[y][x] != -1) return dp[y][x];
if(!(y == h && x == w)){
if(is_prime[y] || is_prime[x]) return dp[y][x] = true;
}
bool res = true;
rep(i, 0, 2){
int ny = y + dy[i];
int nx = x + dx[i];
res &= calc(ny, nx);
}
return dp[y][x] = !res;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
sieve(1000);
while(1){
cin >> h >> w;
rep(i, 0, 1010) rep(j, 0, 1010) dp[i][j] = -1;
cout << (calc(h, w) ? "First" : "Second") << endl;
}
}
treeone