結果
問題 | No.153 石の山 |
ユーザー | pop_o |
提出日時 | 2024-08-30 15:45:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 175,140 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-08-30 15:46:01 |
合計ジャッジ時間 | 3,620 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 10 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> memo(n+1, -1); auto g = [&] (auto self, int a) -> int { if (a == 0) return 0; if (a == 1) return 0; if (memo[a] != -1) return memo[a]; set<int> st; if (a & 1) { st.insert(self(self, a/2)); st.insert(self(self, a/2 + 1)); } else { st.insert(self(self, a/2)); } if (a % 3 == 0) { st.insert(self(self, a/3)); } else { st.insert(self(self, a/3)); st.insert(self(self, a/3+1)); } for (int i = 0; i < 3; i++) { if (st.count(i) == 0) { return memo[a] = i; } } return -1; }; cout << (g(g, n) == 0? "B" : "A") << "\n"; }