結果

問題 No.43 野球の試合
ユーザー SSRSSSRS
提出日時 2020-09-02 06:47:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 85,840 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 10:23:39
合計ジャッジ時間 1,410 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++){
		cin >> s[i];
	}
	vector<int> A, B;
	int S1 = 0, S2 = 0;
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			int id = A.size();
			A.push_back(i);
			B.push_back(j);
			if (s[i][j] != '-'){
				S1 += 1 << id;
				if (s[i][j] == 'o'){
					S2 += 1 << id;
				}
			}
		}
	}
	int M = A.size();
	int ans = N;
	for (int i = 0; i < (1 << M); i++){
		if ((i & S2) == S1){
			vector<int> cnt(N, 0);
			for (int j = 0; j < M; j++){
				if (i >> j & 1){
					cnt[A[j]]++;
				} else {
					cnt[B[j]]++;
				}
			}
			set<int> st;
			for (int j = 0; j < N; j++){
				if (cnt[j] > cnt[0]){
					st.insert(cnt[j]);
				}
			}
			ans = min(ans, (int) st.size() + 1);
		}
	}
	cout << ans << endl;
}
0