結果
問題 |
No.2044 Infinite Nim
|
ユーザー |
![]() |
提出日時 | 2022-08-19 23:20:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 812 ms |
コンパイル使用メモリ | 77,560 KB |
最終ジャッジ日時 | 2025-01-31 01:41:40 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <string> #include <set> #include <algorithm> #include <vector> using namespace std; using ll = long long; bool judge(ll x, ll inf) { if (inf == 0) return false; else if (inf == 1) return true; else if (inf == 2) return x != 0; else return judge(x, inf - 2); } int main() { int n; cin >> n; ll inf = 0; ll x = 0; for (int i=0; i<n; i++) { ll val; cin >> val; if (val == -1) inf++; else x ^= val; } string F = "First", S = "Second"; string ans; if (judge(x, inf)) ans = F; else ans = S; if (inf%2) { ans = F; } else { if (x == 0) { ans = S; } else { ans = F; } } cout << ans << endl; }