結果

問題 No.726 Tree Game
ユーザー kappybarkappybar
提出日時 2020-04-15 17:46:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 170,700 KB
実行使用メモリ 226,176 KB
最終ジャッジ日時 2024-04-09 18:54:20
合計ジャッジ時間 6,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 30000,y_p = 30000;
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