結果

問題 No.43 野球の試合
ユーザー hotpepsihotpepsi
提出日時 2015-06-19 01:25:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 64,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 09:37:13
合計ジャッジ時間 1,226 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0