Submission #1358611
Source Code Expand
#include <iostream> #include <vector> #include <array> #include <map> using namespace std; const int width = 30; const int height = 30; using aii = array<array<int, width>, height>; using vpi = vector<pair<int, int>>; bool inside(const int h, const int w) { if (0 <= w && w < width && 0 <= h && h < height) return true; else return false; } void show(aii &state) { for (auto row : state) { for (auto point : row) { cout << point << " "; } cout << endl; } cout << endl; } void decrement(aii& state, int h, int w, vpi & result) { while (inside(h, w) && state[h][w] != 0) { //show(state); state[h][w]--; result.push_back(pair<int,int>(h,w)); //cout << h << " " << w << endl; int dir[5] = { 0,1,0,-1,0 }; for (int i = 0; i < 4; i++) { if (inside(h + dir[i], w + dir[i + 1]) && state[h][w] == state[h + dir[i]][w + dir[i + 1]]) { h = h + dir[i]; w = w + dir[i + 1]; break; } } } } void input(aii &state) { for (auto & row : state) { for (auto & point : row) { cin >> point; } } } vpi solve(aii& state) { vpi result; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //show(state); while (0 != state[i][j]) { result.push_back(pair<int, int>(i, j)); decrement(state, i, j, result); } } } return result; } int main(void) { aii state; input(state); vpi result = solve(state); //show(state); for (const auto & ans : result) { cout << ans.first + 1 << " " << ans.second + 1 << endl; } }
Submission Info
Submission Time | |
---|---|
Task | A - 高橋君の山崩しゲーム |
User | nasatame |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1614 Byte |
Status | WA |
Exec Time | 84 ms |
Memory | 1016 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 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 100000 | 0 / 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 | WA | 75 ms | 1016 KB |
subtask_01_02.txt | WA | 79 ms | 1016 KB |
subtask_01_03.txt | WA | 77 ms | 1016 KB |
subtask_01_04.txt | WA | 84 ms | 1016 KB |
subtask_01_05.txt | WA | 78 ms | 1016 KB |
subtask_01_06.txt | WA | 77 ms | 1016 KB |
subtask_01_07.txt | WA | 79 ms | 1016 KB |
subtask_01_08.txt | WA | 77 ms | 1016 KB |
subtask_01_09.txt | WA | 79 ms | 1016 KB |
subtask_01_10.txt | WA | 79 ms | 1016 KB |