結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-08-20 14:43:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,544 bytes |
| コンパイル時間 | 1,371 ms |
| コンパイル使用メモリ | 127,312 KB |
| 最終ジャッジ日時 | 2025-01-13 04:24:24 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 48 WA * 2 |
ソースコード
#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(b1<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;
}
chocorusk