Submission #11352439


Source Code Expand

Copy
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/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
Task A - 高橋君の山崩しゲーム
User T_M
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1802 Byte
Status
Exec Time 79 ms
Memory 1404 KB

Test Cases

Set Name Score / Max Score Test Cases
test_01 0 / 100000 subtask_01_01.txt
test_02 0 / 100000 subtask_01_02.txt
test_03 0 / 100000 subtask_01_03.txt
test_04 0 / 100000 subtask_01_04.txt
test_05 0 / 100000 subtask_01_05.txt
test_06 0 / 100000 subtask_01_06.txt
test_07 0 / 100000 subtask_01_07.txt
test_08 0 / 100000 subtask_01_08.txt
test_09 0 / 100000 subtask_01_09.txt
test_10 0 / 100000 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt 72 ms 1404 KB
subtask_01_02.txt 77 ms 1404 KB
subtask_01_03.txt 74 ms 1404 KB
subtask_01_04.txt 79 ms 1404 KB
subtask_01_05.txt 75 ms 1404 KB
subtask_01_06.txt 74 ms 1404 KB
subtask_01_07.txt 76 ms 1404 KB
subtask_01_08.txt 74 ms 1404 KB
subtask_01_09.txt 78 ms 1404 KB
subtask_01_10.txt 77 ms 1404 KB