結果
| 問題 | 
                            No.3112 Decrement or Mod Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             moti
                         | 
                    
| 提出日時 | 2025-04-20 04:11:39 | 
| 言語 | C++17(clang)  (17.0.6 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 928 bytes | 
| コンパイル時間 | 4,672 ms | 
| コンパイル使用メモリ | 138,624 KB | 
| 実行使用メモリ | 11,460 KB | 
| 最終ジャッジ日時 | 2025-04-20 04:11:55 | 
| 合計ジャッジ時間 | 12,838 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 RE * 1 | 
| other | RE * 65 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
// Brute force
int memo[1010][1010][2];
int dfs(int a, int b, bool is_alice) {
  //cout << a << " " << b << endl;
  if (a < 0 || b < 0) throw "a or b is negative";
  assert(a >= 0 && b >= 0);
  if (a - 1 == 0) return is_alice;
  if (a % b == 0) return is_alice;
  if (memo[a][b][is_alice] != -1) return memo[a][b][is_alice];
  if (a >= b) {
    memo[a][b][is_alice] = dfs(b, a % b, !is_alice);
  }
  return memo[a][b][is_alice] = max(memo[a][b][is_alice], (int)dfs(b, a - 1, !is_alice));
}
int main() {
  int a, b; cin >> a >> b;
  if (a > 1000 || b > 1000) {
    throw "a or b is too large";
  }
  rep(i, 1010) rep(j, 1010) rep(k, 2) memo[i][j][k] = -1;
  dfs(a, b, true);  
  cout << (memo[a][b][true] > 0 ? "Alice" : "Bob") << endl;
}
            
            
            
        
            
moti