Contest Duration: ~ (local time) (480 minutes)

Submission #11352439

Source Code Expand

Copy
```/**
* code generated by JHelper
* @author TM
*/

#include <bits/stdc++.h>

#define MOD 1e9+7

using namespace std;

class a {
public:
static void solve(std::istream &cin, std::ostream &cout) {
vector<pair<int64_t, int64_t >> move{{0,  1},
{0,  -1},
{1,  0},
{-1, 0}};
vector<vector<int64_t>> g(30, vector<int64_t>(30));
stack<pair<int64_t, int64_t>> s;
vector<pair<int64_t, int64_t>> res;
for (int i = 0; i < 30; ++i)
for (int j = 0; j < 30; ++j) cin >> g[i][j];
for (int i = 0; i < 30; ++i) {
for (int j = 0; j < 30; ++j) {
s.push(make_pair(i, j));
res.emplace_back(i, j);
while (!s.empty()) {
auto p = s.top();
s.pop();
int64_t x = p.first;
int64_t y = p.second;
if (g[x][y] == 0) continue;
g[x][y]--;
for (const auto &item : move) {
int64_t next_x = x + item.first;
int64_t next_y = y + item.second;
if (next_x < 0 || next_x >= 30 || next_y < 0 || next_y >= 30)continue;
if (g[x][y] != g[next_x][next_y]) continue;
s.push(make_pair(next_x, next_y));
res.emplace_back(next_x, next_y);
}
}
for (int k = 0; k < g[i][j]; ++k) {
res.emplace_back(i, j);
}
}
}
for (const auto &item : res) {
cout << item.first + 1 << " " << item.second + 1 << endl;
}
}
};

int main() {
a solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
```

#### Submission Info

Submission Time 2020-03-30 00:14:31+0900 A - 高橋君の山崩しゲーム T_M C++14 (GCC 5.4.1) 0 1802 Byte WA 79 ms 1404 KB

#### Test Cases

Set Name Score / Max Score Test Cases