Submission #433432
Source Code Expand
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <algorithm>
using namespace std;
inline bool char_exist(int board, int pos)
{
return board & (1 << (pos * 2));
}
inline bool is_chokudai(int board, int pos)
{
return board & (1 << (pos * 2 + 1));
}
inline int ij_pos(int i, int j)
{
return i * 3 + j;
}
int bs[2][3];
int cs[3][2];
int calc_score(int board)
{
//board: 2bitずつ(文字の有無,直大なら1)
int score = 0;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
if (is_chokudai(board, ij_pos(i, j)) == is_chokudai(board, ij_pos(i+1, j)))
{
score += bs[i][j];
}
else
{
}
}
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
if (is_chokudai(board, ij_pos(i, j)) == is_chokudai(board, ij_pos(i, j+1)))
{
score += cs[i][j];
}
else
{
}
}
}
return score;
}
int get_sum_score()
{
int score = 0;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
score += bs[i][j];
}
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
score += cs[i][j];
}
}
return score;
}
int get_max_recur(int board, int remaining, int order)
{
if (remaining == 0)
{
return calc_score(board);
}
int max_score = -10000 * order;
for (int pos = 0; pos < 9; pos++)
{
if (char_exist(board,pos))
{
continue;
}
int next_board = board;
if (order > 0)
{
//chokudai
next_board += (3 << (pos * 2));
}
else
{
//chokuko
next_board += (1 << (pos * 2));
}
int child_score = get_max_recur(next_board, remaining - 1, -order);
if (order > 0)
{
if (child_score > max_score)
{
//chokudaiはスコアが大きくなるように手を打つ
max_score = child_score;
}
}
else
{
if (child_score < max_score)
{
max_score = child_score;
}
}
}
return max_score;
}
int main()
{
scanf("%d %d %d", &bs[0][0], &bs[0][1], &bs[0][2]);
scanf("%d %d %d", &bs[1][0], &bs[1][1], &bs[1][2]);
scanf("%d %d", &cs[0][0], &cs[0][1]);
scanf("%d %d", &cs[1][0], &cs[1][1]);
scanf("%d %d", &cs[2][0], &cs[2][1]);
getchar();
int sum_score = get_sum_score();
int chokudai_score = get_max_recur(0, 9, 1);
printf("%d %d\n", chokudai_score, sum_score - chokudai_score);
#ifdef _DEBUG
printf("Press enter to exit\n");
getchar();
#endif
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
bugtori |
Language |
C++ (GCC 4.9.2) |
Score |
0 |
Code Size |
2578 Byte |
Status |
WA |
Exec Time |
73 ms |
Memory |
804 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:135:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &bs[0][0], &bs[0][1], &bs[0][2]);
^
./Main.cpp:136:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &bs[1][0], &bs[1][1], &bs[1][2]);
^
./Main.cpp:137:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &cs[0][0], &cs[0][1]);
^
./Main.cpp:138:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &cs[1][0], &cs[1][1]);
^
./Main...
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 |
WA |
73 ms |
788 KB |
sample-02.txt |
WA |
72 ms |
668 KB |
test-01.txt |
WA |
70 ms |
800 KB |
test-02.txt |
WA |
71 ms |
668 KB |
test-03.txt |
WA |
71 ms |
804 KB |
test-04.txt |
WA |
69 ms |
672 KB |
test-05.txt |
WA |
71 ms |
792 KB |
test-06.txt |
WA |
70 ms |
796 KB |
test-07.txt |
WA |
70 ms |
800 KB |
test-08.txt |
WA |
70 ms |
804 KB |
test-09.txt |
WA |
70 ms |
800 KB |
test-10.txt |
WA |
72 ms |
796 KB |
test-11.txt |
WA |
71 ms |
672 KB |
test-12.txt |
WA |
72 ms |
804 KB |
test-13.txt |
WA |
72 ms |
800 KB |
test-14.txt |
WA |
71 ms |
672 KB |
test-15.txt |
WA |
71 ms |
716 KB |
test-16.txt |
WA |
70 ms |
804 KB |
test-17.txt |
WA |
70 ms |
700 KB |
test-18.txt |
WA |
69 ms |
800 KB |
test-19.txt |
WA |
70 ms |
672 KB |
test-20.txt |
WA |
71 ms |
796 KB |