結果
問題 | No.2285 Make A Unit Square |
ユーザー |
|
提出日時 | 2023-02-13 08:51:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 226 ms / 2,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 545 ms |
コンパイル使用メモリ | 67,692 KB |
最終ジャッジ日時 | 2025-02-10 14:53:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <iostream> using namespace std; const int NAZO = 34; bool b[2005]; int g[2005]; int grundy(int d) { if(d >= 1000) { return grundy((d - 500) % NAZO + 500); } if (b[d]) { return g[d]; } b[d] = true; bool x[2005]{0}; for (int i = 2; i < d - 1; i++) { x[grundy(i) ^ grundy(d - i)] = true; } for (int i = 0; i <= d; i++) { if (!x[i]) { return g[d] = i; } } return -1; } void solve() { int t; cin >> t; while(t--) { int a, b; cin >> a >> b; if(grundy(a) ^ grundy(b)) { cout << "First" << endl; } else { cout << "Second" << endl; } } } int main() { solve(); }