結果

問題 No.726 Tree Game
ユーザー kappybarkappybar
提出日時 2020-04-15 17:18:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 172,052 KB
実行使用メモリ 28,800 KB
最終ジャッジ日時 2024-10-01 18:55:01
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int prime(int x){
    int res;
    int now = x+1;
    while(1){
        bool ok = true;
        for(int i=2;i*i<=now;i++){
            if(now%i == 0){
                ok = false;
                break;
            }
        }
        if(ok){
            res = now;
            break;
        }else{
            now ++;
        }
    }
    return res;
}

int x_p = 10000,y_p = 10000;
vector<vector<bool>> maze(x_p+1,vector<bool>(y_p+1,false));
vector<vector<bool>> seen(x_p+1,vector<bool>(y_p+1,false));

bool dfs(int i,int j){
    if(seen[i][j]) return maze[i][j];
    seen[i][j] = true;
    if(i==x_p-1 && j==y_p-1) return maze[i][j] = false;
    if(i==x_p || j==y_p) return maze[i][j] = true;
    bool res = !dfs(i+1,j) || !dfs(i,j+1);
    return maze[i][j] = res;
}

int main(){
    int x,y;
    cin >> x >> y;
    x_p = prime(x) - x;
    y_p = prime(y) - y;
    cout << ( dfs(0,0) ? "First" : "Second" ) << endl;
    /*rep(i,x_p+1){
        rep(j,y_p+1) cout << (maze[i][j] ? "Y" : "N") << " ";
        cout << endl;
    }*/
    return 0;
}
0