結果
| 問題 | No.43 野球の試合 | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2015-06-19 01:25:50 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 5 ms / 5,000 ms | 
| コード長 | 909 bytes | 
| コンパイル時間 | 430 ms | 
| コンパイル使用メモリ | 61,720 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-07 03:48:17 | 
| 合計ジャッジ時間 | 887 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <numeric>
using namespace std;
int main(int argc, char *argv[]) {
	string s;
	getline(cin, s);
	stringstream sa(s);
	int N;
	sa >> N;
	string res[6];
	for (int i = 0; i < N; ++i) {
		getline(cin, res[i]);
	}
	int ans = N;
	int m = 1 << (N * (N - 1) / 2);
	for (int b = 0; b < m; ++b) {
		int r[6][6] = {};
		int pos = 0;
		int score[6] = {};
		int f[7] = {};
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (res[i][j] == '-') {
					r[i][j] = ((1 << pos) & b) != 0;
					r[j][i] = r[i][j] ^ 1;
				} else {
					r[i][j] = res[i][j] == 'o';
					r[j][i] = res[j][i] == 'o';
				}
				++pos;
			}
			score[i] = accumulate(r[i], r[i] + N, 0);
			f[score[i]] += 1;
		}
		int a = 1;
		for (int i = N; i > score[0]; --i) {
			if (f[i]) {
				++a;
			}
		}
		ans = min(ans, a);
	}
	cout << ans << endl;
	return 0;
}
            
            
            
        