結果

問題 No.1152 10億ゲーム
ユーザー chocoruskchocorusk
提出日時 2020-08-20 14:35:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,220 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 129,920 KB
実行使用メモリ 24,492 KB
平均クエリ数 24.60
最終ジャッジ日時 2023-09-24 05:45:34
合計ジャッジ時間 10,997 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
24,048 KB
testcase_01 AC 72 ms
23,400 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 72 ms
23,520 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 72 ms
23,412 KB
testcase_09 AC 73 ms
23,544 KB
testcase_10 AC 73 ms
23,664 KB
testcase_11 AC 72 ms
23,844 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 71 ms
23,676 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 72 ms
23,364 KB
testcase_21 AC 73 ms
23,628 KB
testcase_22 AC 72 ms
24,360 KB
testcase_23 AC 73 ms
24,252 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 73 ms
23,832 KB
testcase_39 AC 73 ms
23,652 KB
testcase_40 AC 74 ms
24,348 KB
testcase_41 AC 73 ms
23,844 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 72 ms
24,024 KB
testcase_47 AC 75 ms
23,376 KB
testcase_48 AC 71 ms
23,628 KB
testcase_49 AC 72 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dp[2][10][10][10][10];
P nx[10][10][10][10];
const int INF=100;
int main()
{
	for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                for(int l=0; l<10; l++){
                    if(i==k && j==l){
                        dp[0][i][j][k][l]=dp[1][i][j][k][l]=0;
                    }else{
                        dp[0][i][j][k][l]=dp[1][i][j][k][l]=INF;
                    }
                }
            }
        }
    }
    int dx[4]={1, -1, 0, 0}, dy[4]={0, 0, 1, -1};
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			for(int t=0; t<4; t++){
				int a1=i+dx[t], b1=j+dy[t];
				if(a1<0 || b1<0) continue;
				a1=min(a1, 9), b1=min(b1, 9);
				dp[0][a1][b1][i][j]=0;
				nx[a1][b1][i][j]=P(i, j);
			}
		}
	}
	for(int d=1; d<37; d++){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				for(int k=0; k<10; k++){
					for(int l=0; l<10; l++){
						if(dp[1][i][j][k][l]==INF){
							bool dame=0;
							for(int t=0; t<4; t++){
								int c1=k+dx[t], d1=l+dy[t];
								if(c1<0 || d1<0) continue;
								c1=min(c1, 9), d1=min(d1, 9);
								if(dp[0][i][j][c1][d1]>=d){
									dame=1;
								}
							}
							if(!dame){
								dp[1][i][j][k][l]=d;
							}
						}
					}
				}
			}
		}
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				for(int k=0; k<10; k++){
					for(int l=0; l<10; l++){
						if(dp[0][i][j][k][l]==INF){
							for(int t=0; t<4; t++){
								int c1=i+dx[t], d1=j+dy[t];
								if(c1<0 || d1<0) continue;
								c1=min(c1, 9), d1=min(d1, 9);
								if(dp[1][c1][d1][k][l]<=d){
									dp[0][i][j][k][l]=d;
									nx[i][j][k][l]=P(c1, d1);
									break;
								}
							}
						}
					}
				}
			}
		}
	}
	int x1, x2; cin>>x1>>x2;
    auto myon=[&](int x){
        int a=0, b=0;
        while(x%2==0){
            a++;
            x/=2;
        }
        while(x%5==0){
            b++;
            x/=5;
        }
        return P(a, b);
    };
    auto nuo=[&](int a, int b){
        int x=1;
        for(int i=0; i<a; i++) x*=2;
        for(int i=0; i<b; i++) x*=5;
        return x;
    };
    for(int loop=0; loop<35; loop++){
        P p1=myon(x1), p2=myon(x2);
        int a=p1.first, b=p1.second, c=p2.first, d=p2.second;
        P p3=nx[a][b][c][d];
        int x3=nuo(p3.first, p3.second);
        cout<<x3<<endl;
        if(x3==x2) return 0;
        int x4; cin>>x4;
        if(x3==x4) return 0;
        x1=x3, x2=x4;
    }
	/*
	int mx=0;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			for(int k=0; k<10; k++){
				for(int l=0; l<10; l++){
					mx=max(mx, dp[0][i][j][k][l]);
				}
			}
		}
	}
	cout<<mx<<endl;
	*/
	assert(0);
	return 0;
}
0