結果

問題 No.1152 10億ゲーム
ユーザー chocoruskchocorusk
提出日時 2020-08-20 11:48:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,969 bytes
コンパイル時間 1,347 ms
コンパイル使用メモリ 136,180 KB
実行使用メモリ 24,480 KB
平均クエリ数 24.78
最終ジャッジ日時 2023-09-24 05:42:37
合計ジャッジ時間 7,851 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
24,300 KB
testcase_01 AC 65 ms
24,360 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 65 ms
24,036 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 66 ms
23,820 KB
testcase_09 AC 65 ms
23,388 KB
testcase_10 AC 66 ms
24,048 KB
testcase_11 AC 68 ms
23,988 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 65 ms
24,048 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 65 ms
23,520 KB
testcase_21 AC 65 ms
24,036 KB
testcase_22 AC 65 ms
24,012 KB
testcase_23 AC 66 ms
23,988 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 65 ms
23,964 KB
testcase_39 AC 66 ms
23,820 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 66 ms
23,616 KB
testcase_47 AC 67 ms
23,988 KB
testcase_48 AC 66 ms
24,000 KB
testcase_49 AC 67 ms
23,652 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];
int deg[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 k=0; k<10; k++){
                for(int l=0; l<10; l++){
                    if(i==k && j==l) continue;
                    for(int t=0; t<4; t++){
                        int k1=k+dx[t], l1=l+dy[t];
                        if(k1<0 || k1>=10 || l1<0 || l1>=10) continue;
                        deg[i][j][k1][l1]++;
                    }
                }
            }
        }
    }
    deque<pair<int, pair<P, P>>> que;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            que.push_back({1, {{i, j}, {i, j}}});
        }
    }
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            que.push_back({0, {{i, j}, {i, j}}});
        }
    }
    while(!que.empty()){
        auto p=que.front(); que.pop_front();
        int a=p.second.first.first, b=p.second.first.second, c=p.second.second.first, d=p.second.second.second;
        int t=p.first;
        if(t==1){
            for(int u=0; u<4; u++){
                int a1=a+dx[u], b1=b+dy[u];
                if(a1<0 || a1>=10 || b1<0 || b1>=10) continue;
                if(dp[0][a1][b1][c][d]>dp[1][a][b][c][d]){
                    dp[0][a1][b1][c][d]=dp[1][a][b][c][d];
                    nx[a1][b1][c][d]=P(a, b);
                    que.push_back({0, {{a1, b1}, {c, d}}});
                }
            }
        }else{
            for(int u=0; u<4; u++){
                int c1=c+dx[u], d1=d+dy[u];
                if(c1<0 || c1>=10 || d1<0 || d1>=10) continue;
                deg[a][b][c1][d1]--;
                if(deg[a][b][c1][d1]<=0 && dp[1][a][b][c1][d1]>dp[0][a][b][c][d]+1){
                    dp[1][a][b][c1][d1]=dp[0][a][b][c][d]+1;
                    que.push_front({1, {{a, b}, {c1, d1}}});
                }
            }
        }
    }
    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