Submission #2061647
Source Code Expand
package daicon1; import java.util.Scanner; /** * chokudai contest1 * @author tsukammo */ public class Main { final static int row = 30, col = 30; // map size public static void main(String[] args) { new Main().solve(); } int[][] map = new int[row][col]; // 変更 void solve() { input(); //solveFool(); solveWisdom(); } // Before 4方向探索用 //final static int[] dx = new int[] { 1, 0, 0, -1 }; //final static int[] dy = new int[] { 0, 1, -1, 0 }; // After 4方向探索用 final static int[] dx = new int[] { 0, -1, 0, 1 }; final static int[] dy = new int[] { -1, 0, 1, 0 }; void solveWisdom() { int[] p = chooseTop(); while (p != null) { // 可能な限り連続で崩す while (true) { int x = p[0]; int y = p[1]; System.out.println((x + 1) + " " + (y + 1)); map[x][y]--; // 4方向探索 int[] next = null; for (int d = 0; d < dx.length; d++) { int nx = x + dx[d]; int ny = y + dy[d]; if (outMap(nx, ny)) { continue; } if (map[x][y] == map[nx][ny] && map[nx][ny] > 0) { next = new int[] { nx, ny }; break; } } if (next != null) { p = next; continue; } break; } p = chooseTop(); } } // 山のてっぺんを探す int[] chooseTop() { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (isTop(i, j)) { return new int[] { i, j }; } } } return null; } // 山のてっぺんかを判定 boolean isTop(int x, int y) { for (int d = 0; d < dx.length; d++) { int nx = x + dx[d]; int ny = y + dy[d]; if (outMap(nx, ny)) { continue; } if (map[x][y] <= 0 || map[nx][ny] > map[x][y]) { return false; } } return true; } // 場外判定 boolean outMap(int x, int y) { return !(x > -1 && y > -1 && x < row && y < col); } void input() { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { map[i][j] = sc.nextInt(); } } } void solveFool() { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { while (map[i][j]-- > 0) { System.out.println((i + 1) + " " + (j + 1)); } } } } }
Submission Info
Submission Time | |
---|---|
Task | A - 高橋君の山崩しゲーム |
User | tsukammo |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2358 Byte |
Status | RE |
Exec Time | 84 ms |
Memory | 20948 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 | RE | 84 ms | 19668 KB |
subtask_01_02.txt | RE | 76 ms | 20820 KB |
subtask_01_03.txt | RE | 75 ms | 19412 KB |
subtask_01_04.txt | RE | 77 ms | 17876 KB |
subtask_01_05.txt | RE | 77 ms | 16084 KB |
subtask_01_06.txt | RE | 76 ms | 19540 KB |
subtask_01_07.txt | RE | 76 ms | 19412 KB |
subtask_01_08.txt | RE | 76 ms | 19540 KB |
subtask_01_09.txt | RE | 76 ms | 18900 KB |
subtask_01_10.txt | RE | 77 ms | 20948 KB |