Submission #1756436
Source Code Expand
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
#define m 30
vector<vector<int>> a(m+2),b(m+2);
int x,y;
int nall0(void){
FOR(i,1,m+1) FOR(j,1,m+1) if(a[i][j]!=0){
//x=i;y=j;
return 1;
}
return 0;
}
int search(int x,int y){
if(b[x][y]>0) return b[x][y];
b[x][y]=0;
if(a[x][y]>0) b[x][y]=1;
rep(i,4){
if(a[x+dx[i]][y+dy[i]]==a[x][y]-1 && a[x+dx[i]][y+dy[i]]!=0){
b[x][y]=max(b[x][y],search(x+dx[i],y+dy[i])+1);
}
}
return b[x][y];
}
int main(){
rep(i,m+2){
a[i].resize(m+2);
b[i].resize(m+2);
rep(j,m+2){
if(i*j==0 || i==m+1 || j==m+1) a[i][j]=0;
else cin>>a[i][j];
}
}
bool re=1;
int maxx=0;
int ii,jj;
//int ans=0;
while(nall0()){
maxx=0;
FOR(i,1,m+1) FOR(j,1,m+1) b[i][j]=0;
FOR(i,1,m+1) FOR(j,1,m+1) search(i,j);
FOR(i,1,m+1) FOR(j,1,m+1){
if(maxx<=b[i][j]){
maxx=b[i][j];
ii=i;jj=j;
}
}
x=ii;y=jj;
re=1;
while(re){
re=0;
a[x][y]--;
printf("%d %d\n",x,y);
maxx=0;
rep(i,4){
if(a[x+dx[i]][y+dy[i]]==a[x][y] && a[x+dx[i]][y+dy[i]]!=0){
if(maxx<b[x+dx[i]][y+dy[i]]){
maxx=b[x+dx[i]][y+dy[i]];
ii=x+dx[i];jj=y+dy[i];
re=1;
}
}
}
x=ii;y=jj;
}
//ans++;
}
//cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 高橋君の山崩しゲーム |
User |
IHa |
Language |
C++14 (GCC 5.4.1) |
Score |
763067 |
Code Size |
1782 Byte |
Status |
AC |
Exec Time |
343 ms |
Memory |
512 KB |
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
Score / Max Score |
76503 / 100000 |
76395 / 100000 |
76517 / 100000 |
75656 / 100000 |
75560 / 100000 |
77183 / 100000 |
76307 / 100000 |
76493 / 100000 |
76235 / 100000 |
76218 / 100000 |
Status |
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
337 ms |
512 KB |
subtask_01_02.txt |
AC |
332 ms |
512 KB |
subtask_01_03.txt |
AC |
328 ms |
512 KB |
subtask_01_04.txt |
AC |
343 ms |
512 KB |
subtask_01_05.txt |
AC |
338 ms |
512 KB |
subtask_01_06.txt |
AC |
321 ms |
512 KB |
subtask_01_07.txt |
AC |
332 ms |
512 KB |
subtask_01_08.txt |
AC |
331 ms |
512 KB |
subtask_01_09.txt |
AC |
335 ms |
512 KB |
subtask_01_10.txt |
AC |
332 ms |
512 KB |