結果
| 問題 | No.102 トランプを奪え | 
| コンテスト | |
| ユーザー |  goodbaton | 
| 提出日時 | 2015-08-09 19:39:50 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,426 bytes | 
| コンパイル時間 | 551 ms | 
| コンパイル使用メモリ | 74,236 KB | 
| 実行使用メモリ | 17,344 KB | 
| 最終ジャッジ日時 | 2024-07-18 06:14:51 | 
| 合計ジャッジ時間 | 13,105 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | TLE * 1 -- * 2 | 
| other | -- * 8 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:100:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  100 |     scanf("%d%d%d%d",&a,&b,&c,&d);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:117:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  117 |         scanf("%d%d%d%d%d%d",&n,&m,&o,&p,&q,&r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536
#define SIZE 1000
int memo[2][15][15][15][15][53];
int dfs(int turn,int a,int b,int c,int d,int ta,int ji){
    int ret[4][4],RET;
    int T=ta,J=ji;
    
    if(memo[turn][a+1][b+1][c+1][d+1][T]>0) return memo[turn][a+1][b+1][c+1][d+1][T]-1;
    
    if(a==0 || b==0 || c==0 || d==0){
        if(turn==1){
            //taro
            ta+=(ji+1)/2;
            ji-=(ji+1)/2;
        }else{
            //jiro
            ji+=(ta+1)/2;
            ta-=(ta+1)/2;
        }
        
        if(a==0) a=-1;
        if(b==0) b=-1;
        if(c==0) c=-1;
        if(d==0) d=-1;
    }
    
    if(a==-1 && b==-1 && c==-1 && d==-1){
        
        if(ta>ji){
            return 2;
        }else if(ta==ji){
            return 1;
        }else{
            return 0;
        }
    }
    for(int i=0;i<4;i++)
        for(int j=1;j<=3;j++)
            ret[j][i] = 0+turn*2; //T:0 J:2
    
    for(int i=1;i<=3;i++){
        if(!turn) ta++;
        else ji++;
        
        if(a>=i) ret[i][0] = dfs(!turn,a-i,b,c,d,ta,ji);
        if(b>=i) ret[i][1] = dfs(!turn,a,b-i,c,d,ta,ji);
        if(c>=i) ret[i][2] = dfs(!turn,a,b,c-i,d,ta,ji);
        if(d>=i) ret[i][3] = dfs(!turn,a,b,c,d-i,ta,ji);
    }
    ta-=3;
    ji-=3;
    
    RET = ret[1][0];
    
    for(int j=1;j<=3;j++){
        for(int i=1;i<4;i++){
            if(turn==0){
                //taro
                RET = max(ret[j][i],RET);
            }else{
                //jiro
                RET = min(ret[j][i],RET);
            }
        }
    }
    
    
    memo[turn][a+1][b+1][c+1][d+1][T] = RET+1;
    
    return RET;
    
}
int main(){
    int a,b,c,d,sum,ans;
    
    scanf("%d%d%d%d",&a,&b,&c,&d);
    
    sum = a+b+c+d;
    
    ans = dfs(0,a,b,c,d,0,0);
    
    if(ans==2){
        puts("Taro");
    }else if(ans==0){
        puts("Jiro");
    }else{
        puts("Draw");
    }
    
    int n,m,o,p,q,r,s;
    
    while(1){
        scanf("%d%d%d%d%d%d",&n,&m,&o,&p,&q,&r);
        
        fprintf(stderr," = %d\n",memo[n][m+1][o+1][p+1][q+1][r]-1);
    }
    
    return 0;
}
            
            
            
        