結果

問題 No.2285 Make A Unit Square
ユーザー 👑 emthrmemthrm
提出日時 2023-04-28 21:46:57
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,676 bytes
コンパイル時間 3,250 ms
コンパイル使用メモリ 245,784 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:26:06
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 23 ms
5,376 KB
testcase_03 AC 28 ms
5,376 KB
testcase_04 AC 17 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  // https://oeis.org/A002187
  const vector<int> grundy{8, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 9, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 3, 7, 4};
  const auto f = [&](const int n) -> int {
    if (n < 0 || n == 0 || n == 14 || n == 34) return 0;
    if (n == 16 || n == 17 || n == 31 || n == 51) return 2;
    return grundy[n % grundy.size()];
  };

  int t; cin >> t;
  while (t--) {
    int a, b; cin >> a >> b;
    cout << ((f(a - 3) ^ f(b - 3)) == 0 ? "Second\n" : "First\n");
  }
  return 0;

  // vector<int> grundy(n, 0);
  // FOR(l, 1, n) {
  //   set<int> s{grundy[max(l - 2, 0)]};
  //   FOR(i, 1, l - 1) s.emplace(grundy[i - 1] ^ grundy[l - i - 2]);
  //   while (s.contains(grundy[l])) ++grundy[l];
  // }
  // REP(l, n) cout << grundy[l] << " \n"[l + 1 == n];
}
0