結果

問題 No.43 野球の試合
ユーザー 沙耶花沙耶花
提出日時 2021-10-21 17:49:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 918 bytes
コンパイル時間 4,022 ms
コンパイル使用メモリ 269,344 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 12:29:13
合計ジャッジ時間 5,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000



int main(){
	
	int N;
	cin>>N;
	
	vector<string> S(N);
	rep(i,N){
		cin>>S[i];
	}
	
	vector<pair<int,int>> p;
	rep(i,N){
		for(int j=i+1;j<N;j++){
			p.emplace_back(i,j);
		}
	}
	int ans = Inf;
	
	rep(i,1<<p.size()){
		bool f = true;
		vector<int> win(N,0);
		rep(j,p.size()){
			char c = S[p[j].first][p[j].second];
			if(c=='o'&&((i>>j)&1)==0)f = false;
			if(c=='x'&&((i>>j)&1)==1)f = false;

			if((i>>j)&1){
				win[p[j].first]++;
			}
			else{
				win[p[j].second]++;
			}
		}
		if(!f)continue;
		auto ww = win;
		sort(ww.begin(),ww.end());
		ww.erase(unique(ww.begin(),ww.end()),ww.end());
		ans = min(ans,(int)distance(lower_bound(ww.begin(),ww.end(),win[0]),ww.end()));
	}
	cout<<ans<<endl;
	
	return 0;
}
0