Submission #1138114
Source Code Expand
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string>
#include<unordered_set>
#include<map>
#define p pair<int,int>
#define P pair<int,p>
using namespace std;
int a[30][30];
int dx[4] = { -1,0,0,1 }, dy[4] = { 0,-1,1,0 };
P S[900];
void gyaku(int x,int y){
for (int i =0;i<4;i++) {
int n = x + dx[i], m = y + dy[i];
if (n >= 0 && n < 30 && m >= 0 && m < 30 && a[n][m]!=0 && a[n][m] == a[x][y]+1) {
gyaku(n,m);
break;
}
}
printf("%d %d\n", x+1, y+1);
a[x][y]--;
}
bool T;
void DFS(int x, int y) {
if(T){printf("%d %d\n", x+1, y+1);a[x][y]--;}
T=true;
for (int i =3;i>=0;i--) {
int n = x + dx[i], m = y + dy[i];
if (n >= 0 && n < 30 && m >= 0 && m < 30 && a[n][m]!=0 && a[n][m] == a[x][y]) {
DFS(n, m);
break;
}
}
}
signed main(){
for (int b = 0; b < 30; b++) {
for (int c = 0; c < 30; c++) {
scanf("%d", &a[b][c]);
S[b*30+c]=P(a[b][c],p(b,c));
}
}
sort(S,S+900,greater<P>());
bool Q=true;
do{
Q=false;
for(int i=0;i<900;i++){
int n=S[i].second.first,m=S[i].second.second;
while(a[n][m]){
Q=true;
gyaku(n,m);
T=false;
DFS(n,m);
}
}
}while(Q);
}
Submission Info
Submission Time
2017-03-02 13:03:23+0900
Task
A - 高橋君の山崩しゲーム
User
naoki2016
Language
C++14 (GCC 5.4.1)
Score
819308
Code Size
1238 Byte
Status
AC
Exec Time
8 ms
Memory
512 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:41:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[b][c]);
^
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
81832 / 100000
81873 / 100000
82072 / 100000
81571 / 100000
81424 / 100000
81587 / 100000
82462 / 100000
82068 / 100000
82327 / 100000
82092 / 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
8 ms
512 KB
subtask_01_02.txt
AC
8 ms
512 KB
subtask_01_03.txt
AC
8 ms
512 KB
subtask_01_04.txt
AC
8 ms
512 KB
subtask_01_05.txt
AC
8 ms
512 KB
subtask_01_06.txt
AC
8 ms
512 KB
subtask_01_07.txt
AC
8 ms
512 KB
subtask_01_08.txt
AC
8 ms
512 KB
subtask_01_09.txt
AC
8 ms
512 KB
subtask_01_10.txt
AC
8 ms
512 KB