Submission #3027585
Source Code Expand
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}
int m[5][5];
int b[2][3];
int c[3][2];
int s;
int dp[2];
void init()
{
}
int score()
{
int ret = 0;
REP(i, 3){
REP(j, 3){
if(0 <= i && i <= 1 && 0 <= j && j <= 2){
if(m[i][j] == m[i+1][j]) ret += b[i][j];
}
if(0 <= i && i <= 2 && 0 <= j && j <= 1){
if(m[i][j] == m[i][j+1]) ret += c[i][j];
}
}
}
return ret;
}
int rec(int count)
{
if(count == 9) return score();
int turn = (count % 2 == 0) ? 1 : -1;
int ret = (turn == 1) ? 0 : INF;
REP(i, 3){
REP(j, 3){
if(m[i][j] != 0) continue;
if(turn == 1){
m[i][j] = 1;
ret = max(ret, rec(count+1));
m[i][j] = 0;
}else{
m[i][j] = -1;
ret = min(ret, rec(count+1));
m[i][j] = 0;
}
}
}
return ret;
}
void solve()
{
int first = rec(0);
cout << first << endl;
cout << s - first << endl;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
REP(i, 2){
REP(j, 3){
cin >> b[i][j];
s += b[i][j];
}
}
REP(i, 3){
REP(j, 2){
cin >> c[i][j];
s += c[i][j];
}
}
solve();
return 0;
}
// vim:set foldmethod=marker:
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
rrrccc |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2422 Byte |
Status |
AC |
Exec Time |
33 ms |
Memory |
384 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 |
33 ms |
256 KB |
sample-02.txt |
AC |
33 ms |
256 KB |
test-01.txt |
AC |
33 ms |
384 KB |
test-02.txt |
AC |
33 ms |
256 KB |
test-03.txt |
AC |
33 ms |
256 KB |
test-04.txt |
AC |
33 ms |
256 KB |
test-05.txt |
AC |
33 ms |
256 KB |
test-06.txt |
AC |
33 ms |
256 KB |
test-07.txt |
AC |
33 ms |
256 KB |
test-08.txt |
AC |
33 ms |
256 KB |
test-09.txt |
AC |
33 ms |
256 KB |
test-10.txt |
AC |
33 ms |
256 KB |
test-11.txt |
AC |
33 ms |
256 KB |
test-12.txt |
AC |
33 ms |
256 KB |
test-13.txt |
AC |
33 ms |
256 KB |
test-14.txt |
AC |
33 ms |
256 KB |
test-15.txt |
AC |
33 ms |
256 KB |
test-16.txt |
AC |
33 ms |
256 KB |
test-17.txt |
AC |
33 ms |
256 KB |
test-18.txt |
AC |
33 ms |
256 KB |
test-19.txt |
AC |
33 ms |
256 KB |
test-20.txt |
AC |
33 ms |
256 KB |