結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-04 09:00:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 1,768 bytes |
| コンパイル時間 | 837 ms |
| コンパイル使用メモリ | 89,136 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 14:00:58 |
| 合計ジャッジ時間 | 1,337 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 43.cc: No.43 野球の試合 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 6;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
/* typedef */
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
/* global variables */
string lines[MAX_N];
int gs[MAX_M][2], wins[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> lines[i];
int m = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
gs[m][0] = i, gs[m][1] = j, m++;
//printf("n=%d, m=%d\n", n, m);
int mbits = 1 << m;
int mini = n;
for (int bits = 0; bits < mbits; bits++) {
memset(wins, 0, sizeof(wins));
bool ok = true;
for (int i = 0; ok && i < m; i++) {
int &i0 = gs[i][0], &i1 = gs[i][1];
if ((bits >> i) & 1) {
if (lines[i0][i1] == 'o') ok = false;
else wins[i1]++;
}
else {
if (lines[i0][i1] == 'x') ok = false;
else wins[i0]++;
}
}
if (! ok) continue;
//for (int i = 0; i < n; i++) printf("%d", wins[i]); putchar('\n');
int w0 = wins[0];
sort(wins, wins + n, greater<int>());
int wn = unique(wins, wins + n) - wins;
//printf("wn=%d\n", wn);
for (int i = 0; i < wn; i++)
if (wins[i] == w0 && mini > i) mini = i;
}
printf("%d\n", mini + 1);
return 0;
}
tnakao0123