結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-08-20 12:00:35 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,984 bytes |
| コンパイル時間 | 4,809 ms |
| コンパイル使用メモリ | 165,140 KB |
| 最終ジャッジ日時 | 2025-01-13 04:16:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 RE * 31 TLE * 1 |
ソースコード
#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;
*/
assert(0);
return 0;
}
chocorusk