Submission #2181411
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;
const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;
struct oreno_initializer {
oreno_initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
}
} oreno_initializer;
// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・
int b[2][3], c[3][2], s;
map<mat,int> dp;
int p(mat m) {
int res = 0;
rep(i,2) rep(j,3) if (m[i][j]==m[i+1][j]) res += b[i][j];
rep(i,3) rep(j,2) if (m[i][j]==m[i][j+1]) res += c[i][j];
return res;
}
int rec(mat m, int t) {
if (t==9) return dp[m] = p(m);
if (dp.count(m)) return dp[m];
int dai = (t+1)%2, res = (dai ? -inf : inf);
rep(i,3) rep(j,3) {
if (m[i][j]!=-1) continue;
m[i][j] = dai;
int tmp = rec(m,t+1);
if (dai) chmax(res,tmp);
else chmin(res,tmp);
m[i][j] = -1;
}
return dp[m] = res;
}
signed main() {
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];
}
mat f(3,vi(3,-1));
int dai = rec(f,0);
cout << dai << ln << s-dai << ln;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
creep04 |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2829 Byte |
Status |
AC |
Exec Time |
23 ms |
Memory |
1792 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 |
22 ms |
1792 KB |
sample-02.txt |
AC |
22 ms |
1792 KB |
test-01.txt |
AC |
23 ms |
1792 KB |
test-02.txt |
AC |
22 ms |
1792 KB |
test-03.txt |
AC |
23 ms |
1792 KB |
test-04.txt |
AC |
22 ms |
1792 KB |
test-05.txt |
AC |
22 ms |
1792 KB |
test-06.txt |
AC |
23 ms |
1792 KB |
test-07.txt |
AC |
22 ms |
1792 KB |
test-08.txt |
AC |
22 ms |
1792 KB |
test-09.txt |
AC |
22 ms |
1792 KB |
test-10.txt |
AC |
22 ms |
1792 KB |
test-11.txt |
AC |
22 ms |
1792 KB |
test-12.txt |
AC |
22 ms |
1792 KB |
test-13.txt |
AC |
22 ms |
1792 KB |
test-14.txt |
AC |
22 ms |
1792 KB |
test-15.txt |
AC |
22 ms |
1792 KB |
test-16.txt |
AC |
22 ms |
1792 KB |
test-17.txt |
AC |
22 ms |
1792 KB |
test-18.txt |
AC |
22 ms |
1792 KB |
test-19.txt |
AC |
22 ms |
1792 KB |
test-20.txt |
AC |
22 ms |
1792 KB |