Submission #1625431
Source Code Expand
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン!!!!
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const int inf2 = 1145141919;
const ld pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
bool operator<(S a, S b) { return a.cost < b.cost; }
bool operator>(S a, S b) { return a.cost > b.cost; }
struct H {
int x, y;
};
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad=座標上の2点間の距離
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int b[3][3], c[3][3];
struct A {
int a, b;
};
bool operator+(A a, A b) { return a.a + b.a, a.b + b.b ; }
short a[3][3];
A solve(int x) {
if (x == 9) {
A d = A{ 0,0 };
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
if (a[i][j] == a[i + 1][j])
d.a += b[i][j];
else
d.b += b[i][j];
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
if (a[i][j] == a[i][j + 1])
d.a += c[i][j];
else
d.b += c[i][j];
}
}
return d;
}
A d = A{ 0,0 };
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (!a[i][j]) {
if (x % 2 == 0) {//ちょくだい
a[i][j] = 1;
A e = solve(x + 1);
a[i][j] = 0;
if (e.a > d.a)
d = e;
}
else {//ちょく子
a[i][j] = 2;
A e = solve(x + 1);
a[i][j] = 0;
if (e.b > d.b)
d = e;
}
}
}
}
return d;
}
signed main() {
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
cin >> b[i][j];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 2; j++)
cin >> c[i][j];
cout << solve(0).a<<"\n"<<solve(0).b << endl;
getchar(); getchar();
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
Thistle |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2598 Byte |
Status |
WA |
Exec Time |
63 ms |
Memory |
384 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 |
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 |
WA |
62 ms |
256 KB |
test-05.txt |
WA |
62 ms |
256 KB |
test-06.txt |
WA |
62 ms |
256 KB |
test-07.txt |
AC |
62 ms |
256 KB |
test-08.txt |
AC |
62 ms |
256 KB |
test-09.txt |
AC |
63 ms |
256 KB |
test-10.txt |
AC |
63 ms |
256 KB |
test-11.txt |
AC |
59 ms |
256 KB |
test-12.txt |
WA |
62 ms |
256 KB |
test-13.txt |
WA |
62 ms |
256 KB |
test-14.txt |
AC |
62 ms |
256 KB |
test-15.txt |
WA |
61 ms |
256 KB |
test-16.txt |
AC |
62 ms |
384 KB |
test-17.txt |
WA |
61 ms |
256 KB |
test-18.txt |
AC |
62 ms |
256 KB |
test-19.txt |
WA |
61 ms |
256 KB |
test-20.txt |
AC |
61 ms |
256 KB |