Submission #432765
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int B[4][4],C[4][4];
int T[3][3];
pair<int,int> calc() {
int y,x;
pair<int,int> p={0,0};
FOR(y,2) FOR(x,3) {
if(T[y][x]==T[y+1][x]) p.first += B[y][x];
else p.second += B[y][x];
}
FOR(y,3) FOR(x,2) {
if(T[y][x]==T[y][x+1]) p.first += C[y][x];
else p.second += C[y][x];
}
return p;
}
pair<int,int> dodo(int t) {
pair<int,int> p={0,0};
int y,x;
int did=0;
FOR(y,3) {
FOR(x,3) if(T[y][x]==0) {
did=1;
T[y][x]=t;
pair<int,int> res=dodo(3-t);
if(t==1) {
if(res.first>p.first || (res.first==p.first && res.second<p.second)) p=res;
}
else {
if(res.second>p.second|| (res.second==p.second && res.first<p.first)) p=res;
}
T[y][x]=0;
}
}
if(did==0) return calc();
return p;
}
void solve() {
int i,j,k,l,x,y; string s;
FOR(i,3) cin>>B[0][i];
FOR(i,3) cin>>B[1][i];
FOR(i,2) cin>>C[0][i];
FOR(i,2) cin>>C[1][i];
FOR(i,2) cin>>C[2][i];
pair<int,int> r=dodo(1);
_P("%d\n%d\n",r.first,r.second);
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
kmjp |
Language |
C++11 (GCC 4.9.2) |
Score |
0 |
Code Size |
1701 Byte |
Status |
WA |
Exec Time |
79 ms |
Memory |
928 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
77 ms |
804 KB |
sample-02.txt |
AC |
77 ms |
928 KB |
test-01.txt |
AC |
76 ms |
800 KB |
test-02.txt |
AC |
77 ms |
928 KB |
test-03.txt |
AC |
77 ms |
808 KB |
test-04.txt |
WA |
78 ms |
928 KB |
test-05.txt |
WA |
79 ms |
732 KB |
test-06.txt |
WA |
79 ms |
788 KB |
test-07.txt |
AC |
77 ms |
920 KB |
test-08.txt |
AC |
77 ms |
920 KB |
test-09.txt |
AC |
79 ms |
732 KB |
test-10.txt |
AC |
79 ms |
760 KB |
test-11.txt |
AC |
77 ms |
924 KB |
test-12.txt |
WA |
77 ms |
920 KB |
test-13.txt |
WA |
76 ms |
796 KB |
test-14.txt |
AC |
76 ms |
920 KB |
test-15.txt |
WA |
77 ms |
916 KB |
test-16.txt |
AC |
77 ms |
916 KB |
test-17.txt |
WA |
78 ms |
916 KB |
test-18.txt |
AC |
78 ms |
792 KB |
test-19.txt |
WA |
78 ms |
792 KB |
test-20.txt |
AC |
77 ms |
916 KB |