Submission #1247261
Source Code Expand
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
int M[31][31];
bool check(void) {
REP(i,30)REP(j,30) if(M[i][j] > 0) return true;
return false;
}
pair<int,int> max_pos(void) {
int maxv = -1;
pair<int,int> ret = make_pair(-1,-1);
REP(i,30)REP(j,30) {
if(maxv < M[i][j]) {
maxv = M[i][j];
ret = make_pair(i,j);
}
}
return ret;
}
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
vector<int> idx = {0,1,2,3};
void dfs(int y, int x) {
if(M[y][x] == 0) return;
M[y][x]--;
cout << y+1 << " " << x+1 << endl;
random_shuffle(idx.begin(),idx.end());
REP(i,idx.size()) {
if(x+dx[idx[i]]>0 || x+dx[idx[i]]>=30)continue;
if(y+dy[idx[i]]<0 || y+dy[idx[i]]>=30)continue;
if(M[y+dy[i]][x+dx[i]] == M[y][x]) {
dfs(y+dy[idx[i]],x+dx[idx[i]]);
return;
}
}
}
int main(){
REP(i,30)REP(j,30) cin >> M[i][j];
while(check()) {
pair<int,int> pos = max_pos();
dfs(pos.first,pos.second);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 高橋君の山崩しゲーム |
User |
kosakkun |
Language |
C++14 (GCC 5.4.1) |
Score |
546076 |
Code Size |
1915 Byte |
Status |
AC |
Exec Time |
143 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 |
55986 / 100000 |
53781 / 100000 |
55279 / 100000 |
52405 / 100000 |
55286 / 100000 |
55103 / 100000 |
54251 / 100000 |
55723 / 100000 |
54310 / 100000 |
53952 / 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 |
137 ms |
512 KB |
subtask_01_02.txt |
AC |
140 ms |
512 KB |
subtask_01_03.txt |
AC |
137 ms |
512 KB |
subtask_01_04.txt |
AC |
143 ms |
512 KB |
subtask_01_05.txt |
AC |
141 ms |
512 KB |
subtask_01_06.txt |
AC |
136 ms |
512 KB |
subtask_01_07.txt |
AC |
139 ms |
512 KB |
subtask_01_08.txt |
AC |
135 ms |
512 KB |
subtask_01_09.txt |
AC |
141 ms |
512 KB |
subtask_01_10.txt |
AC |
142 ms |
512 KB |