Submission #3044555
Source Code Expand
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cstdio>
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int dp[513][513];
int b[2][3], c[3][2];
int calc(int x){
int res = 0;
int board[3][3];
for(int i = 2; i >= 0; i--){
for(int j = 2; j >= 0; j--){
board[i][j] = x % 2;
x /= 2;
}
}
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
if(board[i][j] == board[i+1][j])res += b[i][j];
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
if(board[i][j] == board[i][j+1])res += c[i][j];
}
}
return res;
}
int dfs(int x, int y){
if(dp[x][y] != -1)return dp[x][y];
if(x == 511)return calc(y);
vector<int> vec;
int tmp = x;
for(int i = 0; i < 9; i++){
if(tmp % 2 == 0){
vec.pb(i);
}
tmp /= 2;
}
int res = - inf;
if(vec.size() % 2 == 1){
for(auto itr = vec.begin(); itr != vec.end(); ++itr){
res = max(res, dfs(x + (1 << *itr), y + (1 << *itr)));
}
}else{
res = inf;
for(auto itr = vec.begin(); itr != vec.end(); ++itr){
res = min(res, dfs(x + (1 << *itr), y));
}
}
return dp[x][y] = res;
}
int main(int argc, char const* argv[])
{
int sum = 0;
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
scanf("%d", &b[i][j]);
sum += b[i][j];
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
scanf("%d", &c[i][j]);
sum += c[i][j];
}
}
for(int i = 0; i < 513; i++){
for(int j = 0; j < 513; j++){
dp[i][j] = -1;
}
}
int res = dfs(0, 0);
cout << res << endl;
cout << (sum - res) << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
fumiphys |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1995 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
1280 KB |
Compile Error
./Main.cpp: In function ‘int main(int, const char**)’:
./Main.cpp:79:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &b[i][j]);
^
./Main.cpp:85:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &c[i][j]);
^
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 |
3 ms |
1280 KB |
sample-02.txt |
AC |
3 ms |
1280 KB |
test-01.txt |
AC |
3 ms |
1280 KB |
test-02.txt |
AC |
3 ms |
1280 KB |
test-03.txt |
AC |
3 ms |
1280 KB |
test-04.txt |
AC |
3 ms |
1280 KB |
test-05.txt |
AC |
3 ms |
1280 KB |
test-06.txt |
AC |
3 ms |
1280 KB |
test-07.txt |
AC |
3 ms |
1280 KB |
test-08.txt |
AC |
3 ms |
1280 KB |
test-09.txt |
AC |
3 ms |
1280 KB |
test-10.txt |
AC |
3 ms |
1280 KB |
test-11.txt |
AC |
3 ms |
1280 KB |
test-12.txt |
AC |
3 ms |
1280 KB |
test-13.txt |
AC |
3 ms |
1280 KB |
test-14.txt |
AC |
3 ms |
1280 KB |
test-15.txt |
AC |
3 ms |
1280 KB |
test-16.txt |
AC |
3 ms |
1280 KB |
test-17.txt |
AC |
3 ms |
1280 KB |
test-18.txt |
AC |
3 ms |
1280 KB |
test-19.txt |
AC |
3 ms |
1280 KB |
test-20.txt |
AC |
3 ms |
1280 KB |