結果
問題 | No.153 石の山 |
ユーザー |
|
提出日時 | 2024-08-30 15:47:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 920 bytes |
コンパイル時間 | 1,833 ms |
コンパイル使用メモリ | 174,592 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-30 15:47:54 |
合計ジャッジ時間 | 3,273 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 memo[a] = 0;if (a == 1) return memo[a] = 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 <= 5; i++) {if (st.count(i) == 0) {return memo[a] = i;}}return -1;};cout << (g(g, n) == 0? "B" : "A") << "\n";}