Submission #4016206
Source Code Expand
import java.util.Arrays; import java.util.Scanner; public class Main { static int[][] b = new int[2][3]; static int[][] c = new int[3][2]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int sum = 0; for (int y = 0 ; y < 2 ; y++) { for (int x = 0; x < 3 ; x++) { b[y][x] = sc.nextInt(); sum += b[y][x]; } } for (int y = 0 ; y < 3 ; y++ ) { for (int x = 0 ; x < 2 ; x++ ) { c[y][x] = sc.nextInt(); sum += c[y][x]; } } int[][] board = new int[3][3]; for (int i = 0 ; i < 3 ; i++) { Arrays.fill(board[i], -1); } int score = eval(new int[3][3], 1); System.out.println(score); System.out.println(sum - score); } public static int eval(int[][] board, int turn) { if (turn == 10) { return calc(board); } int score = turn % 2 == 1 ? 0 : Integer.MAX_VALUE; for (int y = 0; y < 3 ; y++) { for (int x = 0 ; x < 3 ; x++) { if (board[y][x] == 0) { board[y][x] = 1 + (turn % 2); if (turn % 2 == 1) { score = Math.max(score, eval(board, turn + 1)); } else { score = Math.min(score, eval(board, turn + 1)); } board[y][x] = 0; } } } return score; } public static int calc(int[][] board) { int score = 0; for (int y = 0 ; y < 2 ; y++) { for (int x = 0; x < 3 ; x++) { if (board[y][x] == board[y + 1][x]) { score += b[y][x]; } } } for (int y = 0 ; y < 3 ; y++) { for (int x = 0 ; x < 2 ; x++) { if (board[y][x] == board[y][x + 1]) { score += c[y][x]; } } } return score; } }
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | proteasome |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 2179 Byte |
Status | AC |
Exec Time | 190 ms |
Memory | 26980 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | AC | 190 ms | 20716 KB |
sample-02.txt | AC | 186 ms | 25444 KB |
test-01.txt | AC | 190 ms | 25312 KB |
test-02.txt | AC | 190 ms | 21600 KB |
test-03.txt | AC | 189 ms | 24936 KB |
test-04.txt | AC | 189 ms | 25440 KB |
test-05.txt | AC | 188 ms | 23516 KB |
test-06.txt | AC | 189 ms | 26980 KB |
test-07.txt | AC | 188 ms | 24672 KB |
test-08.txt | AC | 189 ms | 25568 KB |
test-09.txt | AC | 188 ms | 25448 KB |
test-10.txt | AC | 188 ms | 25440 KB |
test-11.txt | AC | 185 ms | 22496 KB |
test-12.txt | AC | 189 ms | 23144 KB |
test-13.txt | AC | 189 ms | 24800 KB |
test-14.txt | AC | 188 ms | 25564 KB |
test-15.txt | AC | 190 ms | 22616 KB |
test-16.txt | AC | 187 ms | 25564 KB |
test-17.txt | AC | 189 ms | 23520 KB |
test-18.txt | AC | 188 ms | 24408 KB |
test-19.txt | AC | 190 ms | 23532 KB |
test-20.txt | AC | 188 ms | 22364 KB |