Submission #3974645
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;
int b[2][3], c[3][2];
P my_max(P a, P b, int type){
if(type == 0){
if(a.first < b.first){
return b;
}else{
return a;
}
}else{
if(a.second < b.second){
return b;
}else{
return a;
}
}
}
P solve(vector< vector<int> > mp, int turn){
P res = {0, 0};
if(turn == 9){
rep(i, 2){
rep(j, 3){
if(mp[i][j] == mp[i + 1][j]){
res.first += b[i][j];
}else{
res.second += b[i][j];
}
}
}
rep(i, 3){
rep(j, 2){
if(mp[i][j] == mp[i][j + 1]){
res.first += c[i][j];
}else{
res.second += c[i][j];
}
}
}
return res;
}
rep(i, 9){
int y = i / 3, x = i % 3;
if(mp[y][x] == -1){
mp[y][x] = turn % 2;
res = my_max(res, solve(mp, turn + 1), turn % 2);
mp[y][x] = -1;
}
}
return res;
}
int main(){
rep(i, 2){
rep(j, 3){
cin >> b[i][j];
}
}
rep(i, 3){
rep(j, 2){
cin >> c[i][j];
}
}
vector< vector<int> > mp(3, vector<int>(3, -1));
P ans = solve(mp, 0);
cout << ans.first << endl << ans.second << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
mhrb |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2185 Byte |
Status |
WA |
Exec Time |
192 ms |
Memory |
256 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 |
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 |
191 ms |
256 KB |
sample-02.txt |
AC |
191 ms |
256 KB |
test-01.txt |
AC |
190 ms |
256 KB |
test-02.txt |
AC |
191 ms |
256 KB |
test-03.txt |
AC |
190 ms |
256 KB |
test-04.txt |
WA |
191 ms |
256 KB |
test-05.txt |
WA |
191 ms |
256 KB |
test-06.txt |
WA |
190 ms |
256 KB |
test-07.txt |
AC |
191 ms |
256 KB |
test-08.txt |
AC |
191 ms |
256 KB |
test-09.txt |
AC |
190 ms |
256 KB |
test-10.txt |
AC |
191 ms |
256 KB |
test-11.txt |
AC |
192 ms |
256 KB |
test-12.txt |
WA |
191 ms |
256 KB |
test-13.txt |
WA |
190 ms |
256 KB |
test-14.txt |
AC |
190 ms |
256 KB |
test-15.txt |
WA |
192 ms |
256 KB |
test-16.txt |
AC |
191 ms |
256 KB |
test-17.txt |
WA |
190 ms |
256 KB |
test-18.txt |
AC |
191 ms |
256 KB |
test-19.txt |
WA |
191 ms |
256 KB |
test-20.txt |
AC |
191 ms |
256 KB |