結果
| 問題 |
No.102 トランプを奪え
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2016-08-30 04:17:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,098 bytes |
| コンパイル時間 | 4,255 ms |
| コンパイル使用メモリ | 168,748 KB |
| 実行使用メモリ | 214,456 KB |
| 最終ジャッジ日時 | 2024-11-14 06:58:40 |
| 合計ジャッジ時間 | 3,123 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef long long ll;
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
using State = array<int, 6>;
int8_t dp[14][14][14][14][53][53][2];
// node: 状態
// depth: 手番。偶数は先手、奇数は後手。
int8_t alphabeta(State& node, int depth, int alpha, int beta) {
int8_t &RET = dp[node[0]][node[1]][node[2]][node[3]][node[4]][node[5]][depth % 2];
if (RET != -1) return RET;
int pla = 4 + depth % 2;
int opo = pla == 4 ? 5 : 4;
bool e = 0;
rep(i, 4) {
rep(j, 1, 4) {
if (node[i] >= j) {
State next(node);
next[i] -= j;
next[pla] += j;
if (next[i] == 0) {
int half = (next[opo] + 1) / 2;
next[pla] += half;
next[opo] -= half;
}
e = 1;
alpha = max(alpha, -alphabeta(next, depth+1, -beta, -alpha));
if (alpha >= beta) {
return RET = alpha;
}
}
}
}
if (!e) return RET = (depth % 2 ? -1 : 1) * (node[4] - node[5]);
return RET = alpha;
}
int minimax(State& node, int depth) {
return alphabeta(node, depth, -1e9, 1e9);
}
void Main() {
int N1, N2, N3, N4;
scanf("%d%d%d%d", &N1, &N2, &N3, &N4);
memset(dp, 0xff, sizeof(dp));
State state {{N1, N2, N3, N4, 0, 0}};
int score = minimax(state, 0);
if (score > 0) puts("Taro");
else if (score < 0) puts("Jiro");
else puts("Draw");
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }
しらっ亭