Submission #432767
Source Code Expand
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define mp make_pair #define pb push_back #define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++) #define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; const int inf = (int)1e9; const double INF = 1e12, EPS = 1e-9; int board[3][3]; int b[3][3], c[3][3]; pi rec(int turn){ if(turn == 9){ int A = 0, B = 0; rep(i, 2) rep(j, 3){ if(board[i][j] == board[i + 1][j]) A += b[i][j]; else B += b[i][j]; } rep(i, 3) rep(j, 2){ if(board[i][j] == board[i][j + 1]) A += c[i][j]; else B += c[i][j]; } return mp(A, B); } pi best(-inf, -inf); rep(i, 3) rep(j, 3) if(board[i][j] == 0){ board[i][j] = turn % 2 + 1; pi tmp = rec(turn + 1); board[i][j] = 0; if(turn % 2 == 0){ if(best.first < tmp.first) best = tmp; } else{ if(best.second < tmp.second) best = tmp; } } return best; } int main(){ rep(i, 2) rep(j, 3) cin >> b[i][j]; rep(i, 3) rep(j, 2) cin >> c[i][j]; pi p = rec(0); cout << p.first << "\n" << p.second << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 双子と○×ゲーム |
User | nadeko |
Language | C++ (GCC 4.9.2) |
Score | 100 |
Code Size | 1288 Byte |
Status | AC |
Exec Time | 73 ms |
Memory | 924 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 | 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 | 71 ms | 796 KB |
sample-02.txt | AC | 70 ms | 800 KB |
test-01.txt | AC | 71 ms | 748 KB |
test-02.txt | AC | 70 ms | 800 KB |
test-03.txt | AC | 72 ms | 924 KB |
test-04.txt | AC | 70 ms | 800 KB |
test-05.txt | AC | 71 ms | 804 KB |
test-06.txt | AC | 71 ms | 800 KB |
test-07.txt | AC | 70 ms | 804 KB |
test-08.txt | AC | 72 ms | 736 KB |
test-09.txt | AC | 70 ms | 800 KB |
test-10.txt | AC | 70 ms | 744 KB |
test-11.txt | AC | 70 ms | 920 KB |
test-12.txt | AC | 72 ms | 860 KB |
test-13.txt | AC | 71 ms | 800 KB |
test-14.txt | AC | 72 ms | 800 KB |
test-15.txt | AC | 70 ms | 672 KB |
test-16.txt | AC | 69 ms | 800 KB |
test-17.txt | AC | 70 ms | 748 KB |
test-18.txt | AC | 72 ms | 804 KB |
test-19.txt | AC | 73 ms | 796 KB |
test-20.txt | AC | 69 ms | 808 KB |