Submission #2405238
Source Code Expand
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <utility> #include <cmath> #include <iomanip> using namespace std; int b11, b12, b13; int b21, b22, b23; int c11, c12; int c21, c22; int c31, c32; int min_max(int _board[3][3], bool first, int t) { int board[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { board[i][j] = _board[i][j]; } } int m = 0; if (t == 9) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (board[i][j] == 0) { board[i][j] = 1; } } } m = 0; if (board[0][0] == board[1][0]) m += b11; if (board[0][1] == board[1][1]) m += b12; if (board[0][2] == board[1][2]) m += b13; if (board[1][0] == board[2][0]) m += b21; if (board[1][1] == board[2][1]) m += b22; if (board[1][2] == board[2][2]) m += b23; if (board[0][0] == board[0][1]) m += c11; if (board[0][1] == board[0][2]) m += c12; if (board[1][0] == board[1][1]) m += c21; if (board[1][1] == board[1][2]) m += c22; if (board[2][0] == board[2][1]) m += c31; if (board[2][1] == board[2][2]) m += c32; } else if (first) { m = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (board[i][j] == 0) { board[i][j] = 1; m = max(m, min_max(board, false, t+1)); board[i][j] = 0; } } } } else { m = (int) 1e9; bool flag = true; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (board[i][j] == 0) { board[i][j] = 2; flag = false; m = min(m, min_max(board, true, t+1)); board[i][j] = 0; } } } } return m; } int main() { cin >> b11 >> b12 >> b13; cin >> b21 >> b22 >> b23; cin >> c11 >> c12; cin >> c21 >> c22; cin >> c31 >> c32; int board[3][3] = {}; int first = min_max(board, true, 1); int sum = 0; sum += b11 + b12 + b13; sum += b21 + b22 + b23; sum += c11 + c12; sum += c21 + c22; sum += c31 + c32; int second = sum - first; cout << first << endl; cout << second << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | bluenote |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 2590 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 256 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 | 15 ms | 256 KB |
sample-02.txt | AC | 15 ms | 256 KB |
test-01.txt | AC | 15 ms | 256 KB |
test-02.txt | AC | 15 ms | 256 KB |
test-03.txt | AC | 15 ms | 256 KB |
test-04.txt | AC | 15 ms | 256 KB |
test-05.txt | AC | 15 ms | 256 KB |
test-06.txt | AC | 15 ms | 256 KB |
test-07.txt | AC | 15 ms | 256 KB |
test-08.txt | AC | 15 ms | 256 KB |
test-09.txt | AC | 15 ms | 256 KB |
test-10.txt | AC | 15 ms | 256 KB |
test-11.txt | AC | 15 ms | 256 KB |
test-12.txt | AC | 15 ms | 256 KB |
test-13.txt | AC | 15 ms | 256 KB |
test-14.txt | AC | 15 ms | 256 KB |
test-15.txt | AC | 15 ms | 256 KB |
test-16.txt | AC | 15 ms | 256 KB |
test-17.txt | AC | 15 ms | 256 KB |
test-18.txt | AC | 15 ms | 256 KB |
test-19.txt | AC | 15 ms | 256 KB |
test-20.txt | AC | 15 ms | 256 KB |