Submission #3730344
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
fill((T *)array, (T *)(array + N), val);
}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];
ll b[2][3] ,c[3][2];
ll solve(bool C,int used[3][3]){
ll M = -114514,m = 114514;
bool ok = true;
REP(i,3)REP(j,3){
int unko[3][3] = {};
REP(i,3)REP(j,3)unko[i][j] = used[i][j];
if(used[i][j] == 0){
ok = false;
if(C)unko[i][j] = 1;
else unko[i][j] = 2;
ll tmp = solve(!C,unko);
M = max(tmp,M);
m = min(tmp,m);
}
}
if(!ok){
return (C ? M : m);
}
else{
ll dif = 0;
REP(i,2)REP(j,3){
if(used[i][j] == used[i + 1][j])dif += b[i][j];
else dif -= b[i][j];
}
REP(i,3)REP(j,2){
if(used[i][j] == used[i][j + 1])dif += c[i][j];
else dif -= c[i][j];
}
return dif;
}
}
signed main(){
IOS;
ll sum = 0;
REP(i,2)REP(j,3){
cin >> b[i][j];
sum += b[i][j];
}
REP(i,3)REP(j,2){
cin >> c[i][j];
sum += c[i][j];
}
int used[3][3] = {};
ll dif = solve(true,used);
cout << (sum + dif) / 2 << endl;
cout << (sum - dif) / 2 << endl;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
jgvt5ti |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1631 Byte |
Status |
AC |
Exec Time |
67 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 |
67 ms |
256 KB |
sample-02.txt |
AC |
67 ms |
256 KB |
test-01.txt |
AC |
67 ms |
256 KB |
test-02.txt |
AC |
67 ms |
256 KB |
test-03.txt |
AC |
67 ms |
256 KB |
test-04.txt |
AC |
67 ms |
256 KB |
test-05.txt |
AC |
67 ms |
256 KB |
test-06.txt |
AC |
67 ms |
256 KB |
test-07.txt |
AC |
67 ms |
256 KB |
test-08.txt |
AC |
67 ms |
256 KB |
test-09.txt |
AC |
67 ms |
256 KB |
test-10.txt |
AC |
67 ms |
256 KB |
test-11.txt |
AC |
67 ms |
256 KB |
test-12.txt |
AC |
67 ms |
256 KB |
test-13.txt |
AC |
67 ms |
256 KB |
test-14.txt |
AC |
67 ms |
256 KB |
test-15.txt |
AC |
67 ms |
256 KB |
test-16.txt |
AC |
67 ms |
256 KB |
test-17.txt |
AC |
67 ms |
256 KB |
test-18.txt |
AC |
67 ms |
256 KB |
test-19.txt |
AC |
67 ms |
256 KB |
test-20.txt |
AC |
67 ms |
256 KB |