Submission #3901193
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template < typename T >
void vprint(T &v){
REP(i, v.size()){
cout << v[i] << " ";
}
cout << endl;
}
ll b[2][3];
ll c[3][2];
void print_state(vector<ll> &state){
REP(i, 3){
REP(j, 3){
cout << state[3*i+j] << " ";
}
cout << endl;
}
return;
}
ll score(vector<ll> &state){
if(state.size()!=9) cout << "invalid length input" << endl;
ll sum = 0;
REP(i, 2)REP(j, 3){
sum += (b[i][j]*(state[j+3*i]==state[j+3*i+3]));
}
REP(i, 3)REP(j, 2){
sum += (c[i][j]*(state[j+3*i]==state[j+1+3*i]));
}
/*
print_state(state);
dump(sum)
cout << endl;
*/
return sum;
}
ll rec(vector<ll> &state, ll depth){
if(depth==9) return score(state);
ll res;
if(depth%2==0){
res = -1;
REP(i, 9){
if(state[i]==-1){
vector<ll> state_copy(9);
REP(j, 9) state_copy[j] = state[j];
state_copy[i] = 1;
res = max(rec(state_copy, depth+1), res);
}
}
}else{
res = 1010101010;
REP(i, 9){
if(state[i]==-1){
vector<ll> state_copy(9);
REP(j, 9) state_copy[j] = state[j];
state_copy[i] = 0;
res = min(rec(state_copy, depth+1), res);
}
}
}
return res;
}
int main(){
REP(i, 2)REP(j, 3) cin >> b[i][j];
REP(i, 3)REP(j, 2) cin >> c[i][j];
ll sum = 0;
REP(i, 2)REP(j, 3) sum += b[i][j];
REP(i, 3)REP(j, 2) sum += c[i][j];
vector<ll> start(9, -1);
ll res = rec(start, 0);
cout << res << endl;
cout << sum - res << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
theory_and_me |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1911 Byte |
Status |
AC |
Exec Time |
63 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 |
62 ms |
256 KB |
sample-02.txt |
AC |
62 ms |
256 KB |
test-01.txt |
AC |
62 ms |
256 KB |
test-02.txt |
AC |
62 ms |
256 KB |
test-03.txt |
AC |
62 ms |
256 KB |
test-04.txt |
AC |
62 ms |
256 KB |
test-05.txt |
AC |
62 ms |
256 KB |
test-06.txt |
AC |
62 ms |
256 KB |
test-07.txt |
AC |
62 ms |
256 KB |
test-08.txt |
AC |
62 ms |
256 KB |
test-09.txt |
AC |
62 ms |
256 KB |
test-10.txt |
AC |
62 ms |
256 KB |
test-11.txt |
AC |
62 ms |
256 KB |
test-12.txt |
AC |
62 ms |
256 KB |
test-13.txt |
AC |
62 ms |
256 KB |
test-14.txt |
AC |
62 ms |
256 KB |
test-15.txt |
AC |
62 ms |
256 KB |
test-16.txt |
AC |
62 ms |
256 KB |
test-17.txt |
AC |
62 ms |
256 KB |
test-18.txt |
AC |
62 ms |
256 KB |
test-19.txt |
AC |
62 ms |
256 KB |
test-20.txt |
AC |
63 ms |
256 KB |