Submission #1247295


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const int MAX_N = 500000 + 10;
int b[2][3];
int c[3][2];

int t[3][3];

pair<int,int> score() {
  int x = 0, y = 0;
  REP(i, 3) REP(j, 3) {
    if (i + 1 < 3) (t[i][j] == t[i+1][j] ? x : y) += b[i][j];
    if (j + 1 < 3) (t[i][j] == t[i][j+1] ? x : y) += c[i][j];
  }
  return {x, y};
}

pair<int,int> dfs(int turn) {
  if (turn == 9) {
    return score();
  }

  pair<int,int> ans = {-1, -1};
  int mark = turn % 2 == 0 ? +1 : -1;
  REP(i, 3) REP(j, 3) if (t[i][j] == 0) {
    t[i][j] = mark;
    pair<int,int> here = dfs(turn + 1);
    t[i][j] = 0;

    if (turn % 2 == 0) {
      if (ans.first < here.first) ans = here;
    } else {
      if (ans.second < here.second) ans = here;
    }
  }
  return ans;
}

int main2() {
  REP(i, 2) REP(j, 3) b[i][j] = nextInt();
  REP(i, 3) REP(j, 2) c[i][j] = nextInt();

  memset(t, 0, sizeof(t));

  pair<int,int> ans = dfs(0);
  cout << ans.first << endl;
  cout << ans.second << endl;
  return 0;

}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Submission Info

Submission Time
Task C - 双子と○×ゲーム
User hs484
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1422 Byte
Status AC
Exec Time 34 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int nextInt()’:
./Main.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x); return x;
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 24
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 33 ms 256 KB
sample-02.txt AC 33 ms 256 KB
test-01.txt AC 33 ms 256 KB
test-02.txt AC 33 ms 256 KB
test-03.txt AC 33 ms 256 KB
test-04.txt AC 33 ms 256 KB
test-05.txt AC 33 ms 256 KB
test-06.txt AC 34 ms 256 KB
test-07.txt AC 33 ms 256 KB
test-08.txt AC 33 ms 256 KB
test-09.txt AC 33 ms 256 KB
test-10.txt AC 33 ms 256 KB
test-11.txt AC 32 ms 256 KB
test-12.txt AC 33 ms 256 KB
test-13.txt AC 33 ms 256 KB
test-14.txt AC 33 ms 256 KB
test-15.txt AC 33 ms 256 KB
test-16.txt AC 33 ms 256 KB
test-17.txt AC 33 ms 256 KB
test-18.txt AC 33 ms 256 KB
test-19.txt AC 33 ms 256 KB
test-20.txt AC 33 ms 256 KB