Submission #8244741
Source Code Expand
#include <iostream>
#include <array>
using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
const int SIZE = 30;
const array<int, 4> dx = {-1, 0, 0, 1};
const array<int, 4> dy = {0, -1, 1, 0};
array<array<int, SIZE>, SIZE> a;
bool is_out(int x, int y){
return (x < 0 || x >= SIZE || y < 0 || y >= SIZE);
}
bool is_top(int x, int y){
REP(k, dx.size()){
if(is_out(x + dx[k], y + dy[k])){
continue;
}else if(a[x + dx[k]][y + dy[k]] > a[x][y]){
return false;
}
}
return true;
}
int main(){
REP(i, SIZE){
REP(j, SIZE){
cin >> a[i][j];
}
}
while(1){
bool found = false;
int sx = 0, sy = 0;
REP(i, 2 * (SIZE - 1) + 1){
REP(x, i + 1){
const int y = i - x;
if(is_out(x, y)){ continue; }
if(a[x][y] == 0){ continue; }
if(is_top(x, y)){
sx = x;
sy = y;
found = true;
}
if(found){ break; }
}
if(found){ break; }
}
// REP(i, SIZE){
// REP(j, SIZE){
// if(a[i][j] == 0){ continue; }
// if(is_top(i, j)){
// sx = i;
// sy = j;
// found = true;
// }
// if(found){ break; }
// }
// if(found){ break; }
// }
if(a[sx][sy] == 0){
break;
}
cout << sx + 1 << ' ' << sy + 1 << endl;
a[sx][sy]--;
while(a[sx][sy] > 0){
bool moved = false;
REP(k, dx.size()){
if(is_out(sx + dx[k], sy + dy[k])){
continue;
}else if(a[sx + dx[k]][sy + dy[k]] == a[sx][sy]){
sx += dx[k];
sy += dy[k];
a[sx][sy]--;
cout << sx + 1 << ' ' << sy + 1 << endl;
moved = true;
break;
}
}
if(!moved){
break;
}
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 高橋君の山崩しゲーム |
User |
sensaur |
Language |
C++14 (Clang 3.8.0) |
Score |
870753 |
Code Size |
2341 Byte |
Status |
AC |
Exec Time |
128 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 |
87413 / 100000 |
86741 / 100000 |
87134 / 100000 |
86752 / 100000 |
86953 / 100000 |
86504 / 100000 |
87681 / 100000 |
86935 / 100000 |
87131 / 100000 |
87509 / 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 |
122 ms |
512 KB |
subtask_01_02.txt |
AC |
127 ms |
512 KB |
subtask_01_03.txt |
AC |
125 ms |
512 KB |
subtask_01_04.txt |
AC |
128 ms |
512 KB |
subtask_01_05.txt |
AC |
124 ms |
512 KB |
subtask_01_06.txt |
AC |
123 ms |
512 KB |
subtask_01_07.txt |
AC |
127 ms |
512 KB |
subtask_01_08.txt |
AC |
120 ms |
512 KB |
subtask_01_09.txt |
AC |
126 ms |
512 KB |
subtask_01_10.txt |
AC |
125 ms |
512 KB |