AtCoder Beginner Contest 025

Submission #1672707

Source codeソースコード

#include <iostream>
#include <sstream>
#include <vector>
#include <assert.h>
#include <algorithm>
using namespace std;

#define REP(i,a,b) for(int i = a; i < (int)b;i++)
#define rep(i, n) REP(i,0,n)
int B[2][3], C[3][2];
int board[3][3];

pair<int, int> dfs(bool is_man, int cnt) {
  if (cnt == 9) {
    int man = 0, woman = 0;
    rep(i, 2) rep(j, 3) {
      (board[i][j] == board[i + 1][j] ? man : woman) += B[i][j];
    }
    rep(i, 3) rep(j, 2) {
      (board[i][j] == board[i][j + 1] ? man : woman) += C[i][j];
    }
    return {man, woman};
  }

  pair<int, int> ret;
  rep(i, 3) rep(j, 3) {
    if (board[i][j] == -1) {
      board[i][j] = is_man;
      auto r = dfs(!is_man, cnt + 1);
      bool cond = is_man ?
        ret.first < r.first : ret.second < r.second;
      if (cond) {
        ret = r;
      }
      cond = is_man ?
        (ret.first == r.first && ret.second > r.second) :
        (ret.second == r.second && ret.first > r.first);
      if (cond) {
        ret = r;
      }
      board[i][j] = -1;
    }
  }
  return ret;
}

int main() {
  rep(i, 3) rep(j, 3) board[i][j] = -1;
  rep(i, 2) rep(j, 3) cin >> B[i][j];
  rep(i, 3) rep(j, 2) cin >> C[i][j];
  auto r = dfs(true, 0);
  std::cout << r.first << "\n" << r.second << "\n";
}

Submission

Task問題 C - 双子と○×ゲーム
User nameユーザ名 motxx
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1306 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample-01.txt,sample-02.txt
All 0 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample-01.txt AC 30 ms 256 KB
sample-02.txt AC 30 ms 256 KB
test-01.txt AC 30 ms 256 KB
test-02.txt AC 30 ms 256 KB
test-03.txt AC 30 ms 256 KB
test-04.txt WA
test-05.txt WA
test-06.txt WA
test-07.txt AC 30 ms 256 KB
test-08.txt AC 30 ms 256 KB
test-09.txt AC 29 ms 256 KB
test-10.txt AC 30 ms 256 KB
test-11.txt AC 29 ms 256 KB
test-12.txt WA
test-13.txt WA
test-14.txt AC 30 ms 256 KB
test-15.txt WA
test-16.txt AC 30 ms 256 KB
test-17.txt WA
test-18.txt AC 30 ms 256 KB
test-19.txt WA
test-20.txt AC 30 ms 256 KB