結果

問題 No.43 野球の試合
ユーザー nenuonnenuon
提出日時 2017-06-25 12:54:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,394 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 90,296 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-27 13:20:04
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
// kくんは全て勝つ
// 全探索
typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  vector<string> vs;
  FOR(i,0,N){
    string s;
    cin >> s;
    vs.push_back(s);
  }
  vector<P> vp;
  int win[N];
  FOR(i,0,N) {
    win[i] = 0;
  }
  FOR(i,0,N){
    FOR(j,i,N){
      if(vs[i][j] == 'o') {
        win[i]++;
      }
      if(vs[i][j] == 'x') {
        win[j]++;
      }
      if(vs[i][j] == '-'){
        if(i == 0) {
          vs[i][j] = 'o';
          vs[j][i] = 'x';
          win[i]++;
        } else {
          vp.push_back(P(i,j));
        }
      }
    }
  }

  int ans = 10;
  int len = vp.size();
  FOR(i,0,1<<len){
    int winwin[N];
    FOR(j,0,N) {
      winwin[j] = win[j];
    }
    FOR(j,0,len){
      if((i>>j) & 1){
        winwin[vp[j].first]++;
      } else {
        winwin[vp[j].second]++;
      }
    }
    int tmp = 1;
    int now = winwin[0];
    FOR(i,1,N){
      if(now<winwin[i]){
        tmp++;
        now = winwin[i];
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
0