結果

問題 No.726 Tree Game
ユーザー ei1333333ei1333333
提出日時 2018-08-24 21:27:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 206,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 10:57:41
合計ジャッジ時間 3,252 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

bool prime(int i) {
  for(int j = 2; j * j <= i; j++) {
    if(i % j == 0) return false;
  }
  return true;
}

map< pair< int, int >, int > dp;

bool check(int Y, int X) {
  if(dp.count({Y, X})) return dp[{Y, X}];
  bool f = false;
  if(!prime(Y + 1) && !prime(X)) f |= !check(Y + 1, X);
  if(!prime(Y) && !prime(X + 1)) f |= !check(Y, X + 1);
  return dp[{Y, X}] = f;
}

int main() {
  int Y, X;
  cin >> Y >> X;
  if(check(Y, X)) cout << "First" << endl;
  else cout << "Second" << endl;
}
0