Submission #668316
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <utility>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<int,int> pii;
int a[32][32]={};
int c =0;
void read(){
rep(i,30)rep(j,30){
scanf("%d",&a[i+1][j+1]);
}
}
pii next(pii p){
pii temp = make_pair(0,0);
if(a[p.first][p.second]==a[p.first+1][p.second]&&a[p.first][p.second]!=0){
temp.first = p.first +1;
temp.second = p.second;
if(a[temp.first][temp.second]==1) c++;
a[temp.first][temp.second]--;
printf("%d %d\n",temp.first,temp.second);
return temp;
}
else if(a[p.first][p.second]==a[p.first][p.second+1]&&a[p.first][p.second]!=0){
temp.first = p.first;
temp.second = p.second +1;
if(a[temp.first][temp.second]==1) c++;
a[temp.first][temp.second]--;
printf("%d %d\n",temp.first,temp.second);
return temp;
}
else if(a[p.first][p.second]==a[p.first-1][p.second]&&a[p.first][p.second]!=0){
temp.first = p.first -1;
temp.second = p.second;
if(a[temp.first][temp.second]==1) c++;
a[temp.first][temp.second]--;
printf("%d %d\n",temp.first,temp.second);
return temp;
}
else if(a[p.first][p.second]==a[p.first][p.second-1]&&a[p.first][p.second]!=0){
temp.first = p.first;
temp.second = p.second -1;
if(a[temp.first][temp.second]==1) c++;
a[temp.first][temp.second]--;
printf("%d %d\n",temp.first,temp.second);
return temp;
}
else{
return temp;
}
}
bool check(){
bool flag = true;
rep(i,30)rep(j,30){
if(a[i][j]!=0){
flag = false;
return flag;
}
}
return flag;
}
pii first(){
pii temp = make_pair(0,0);
rep(i,30)rep(j,30){
if(a[i+1][j+1]>a[temp.first][temp.second]){
temp = make_pair(i+1,j+1);
}
}
printf("%d %d\n",temp.first,temp.second);
if(a[temp.first][temp.second]==1) c++;
a[temp.first][temp.second]--;
return temp;
}
int main(){
read();
while(c<900){
pii k = first();
while(1){
k = next(k);
if(k.first == 0 && k.second == 0){
break;
}
}
}
return 0;
}
Submission Info
Submission Time
2016-03-20 16:35:49+0900
Task
A - 高橋君の山崩しゲーム
User
polyomino
Language
C++14 (GCC 5.4.1)
Score
791941
Code Size
2414 Byte
Status
AC
Exec Time
58 ms
Memory
384 KB
Compile Error
./Main.cpp: In function ‘void read()’:
./Main.cpp:12:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i+1][j+1]);
^
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
79227 / 100000
78582 / 100000
79900 / 100000
78365 / 100000
79132 / 100000
79421 / 100000
79552 / 100000
79401 / 100000
79143 / 100000
79218 / 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
56 ms
384 KB
subtask_01_02.txt
AC
58 ms
384 KB
subtask_01_03.txt
AC
55 ms
384 KB
subtask_01_04.txt
AC
58 ms
384 KB
subtask_01_05.txt
AC
56 ms
384 KB
subtask_01_06.txt
AC
56 ms
384 KB
subtask_01_07.txt
AC
56 ms
384 KB
subtask_01_08.txt
AC
55 ms
384 KB
subtask_01_09.txt
AC
56 ms
384 KB
subtask_01_10.txt
AC
56 ms
384 KB