結果

問題 No.1152 10億ゲーム
ユーザー chocoruskchocorusk
提出日時 2020-08-20 14:42:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,544 bytes
コンパイル時間 1,310 ms
コンパイル使用メモリ 130,204 KB
実行使用メモリ 24,384 KB
平均クエリ数 22.74
最終ジャッジ日時 2023-09-24 05:45:50
合計ジャッジ時間 7,649 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
23,520 KB
testcase_01 AC 71 ms
23,388 KB
testcase_02 AC 71 ms
24,348 KB
testcase_03 AC 72 ms
23,988 KB
testcase_04 AC 70 ms
23,400 KB
testcase_05 AC 72 ms
24,024 KB
testcase_06 AC 72 ms
24,348 KB
testcase_07 AC 73 ms
23,352 KB
testcase_08 AC 70 ms
23,364 KB
testcase_09 AC 71 ms
24,012 KB
testcase_10 AC 71 ms
23,616 KB
testcase_11 AC 70 ms
23,976 KB
testcase_12 AC 72 ms
24,252 KB
testcase_13 AC 73 ms
23,640 KB
testcase_14 AC 73 ms
23,628 KB
testcase_15 AC 72 ms
23,604 KB
testcase_16 AC 72 ms
23,796 KB
testcase_17 AC 72 ms
23,796 KB
testcase_18 AC 73 ms
24,000 KB
testcase_19 AC 73 ms
24,024 KB
testcase_20 AC 70 ms
23,412 KB
testcase_21 AC 70 ms
23,964 KB
testcase_22 AC 71 ms
23,628 KB
testcase_23 AC 71 ms
23,832 KB
testcase_24 AC 71 ms
23,376 KB
testcase_25 AC 73 ms
24,360 KB
testcase_26 AC 72 ms
23,616 KB
testcase_27 AC 74 ms
24,384 KB
testcase_28 AC 73 ms
24,024 KB
testcase_29 AC 73 ms
23,508 KB
testcase_30 AC 73 ms
23,976 KB
testcase_31 AC 72 ms
23,328 KB
testcase_32 AC 71 ms
23,400 KB
testcase_33 AC 71 ms
23,988 KB
testcase_34 AC 71 ms
23,544 KB
testcase_35 AC 72 ms
23,532 KB
testcase_36 AC 72 ms
23,616 KB
testcase_37 AC 71 ms
23,388 KB
testcase_38 AC 72 ms
23,604 KB
testcase_39 AC 71 ms
23,988 KB
testcase_40 AC 71 ms
24,348 KB
testcase_41 AC 68 ms
23,988 KB
testcase_42 AC 71 ms
23,400 KB
testcase_43 AC 70 ms
24,372 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 70 ms
23,364 KB
testcase_47 AC 69 ms
24,300 KB
testcase_48 AC 70 ms
24,312 KB
testcase_49 AC 71 ms
23,364 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;
				if(a1==10){
					if(a1<9) continue;
					else a1=9;
				}else if(b1==10){
					if(a1<7) continue;
					else a1=9, 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;
								if(c1==10){
									if(d1<9) continue;
									else c1=9;
								}else if(d1==10){
									if(c1<7) continue;
									else c1=9, 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;
								if(c1==10){
									if(d1<9) continue;
									else c1=9;
								}else if(d1==10){
									if(c1<7) continue;
									else c1=9, 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;
	*/
	return 0;
}
0