Submission #1672704
Source Code Expand
#include <iostream>
#include <sstream>
#include <vector>
#include <assert.h>
#include <algorithm>
using namespace std;
#define REP(i,a,b) for(int i = a; i < (int)b;i++)
#define rep(i, n) REP(i,0,n)
int B[2][3], C[3][2];
int board[3][3];
pair<int, int> dfs(bool is_man, int cnt) {
if (cnt == 9) {
int man = 0, woman = 0;
rep(i, 2) rep(j, 3) {
(board[i][j] == board[i + 1][j] ? man : woman) += B[i][j];
}
rep(i, 3) rep(j, 2) {
(board[i][j] == board[i][j + 1] ? man : woman) += C[i][j];
}
return {man, woman};
}
pair<int, int> ret;
rep(i, 3) rep(j, 3) {
if (board[i][j] == -1) {
board[i][j] = is_man;
auto r = dfs(!is_man, cnt + 1);
bool cond = is_man ?
ret.first < r.first : ret.second < r.second;
if (cond) {
ret = r;
}
board[i][j] = -1;
}
}
return ret;
}
int main() {
rep(i, 3) rep(j, 3) board[i][j] = -1;
rep(i, 2) rep(j, 3) cin >> B[i][j];
rep(i, 3) rep(j, 2) cin >> C[i][j];
auto r = dfs(true, 0);
std::cout << r.first << "\n" << r.second << "\n";
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
motxx |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1120 Byte |
Status |
WA |
Exec Time |
29 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
28 ms |
256 KB |
sample-02.txt |
AC |
28 ms |
256 KB |
test-01.txt |
AC |
28 ms |
256 KB |
test-02.txt |
AC |
28 ms |
256 KB |
test-03.txt |
AC |
29 ms |
256 KB |
test-04.txt |
WA |
28 ms |
256 KB |
test-05.txt |
WA |
28 ms |
256 KB |
test-06.txt |
WA |
28 ms |
256 KB |
test-07.txt |
AC |
29 ms |
256 KB |
test-08.txt |
AC |
28 ms |
256 KB |
test-09.txt |
AC |
28 ms |
256 KB |
test-10.txt |
AC |
29 ms |
256 KB |
test-11.txt |
AC |
28 ms |
256 KB |
test-12.txt |
WA |
28 ms |
256 KB |
test-13.txt |
WA |
28 ms |
256 KB |
test-14.txt |
AC |
29 ms |
256 KB |
test-15.txt |
WA |
28 ms |
256 KB |
test-16.txt |
AC |
28 ms |
256 KB |
test-17.txt |
WA |
28 ms |
256 KB |
test-18.txt |
AC |
29 ms |
256 KB |
test-19.txt |
WA |
28 ms |
256 KB |
test-20.txt |
AC |
28 ms |
256 KB |