結果

問題 No.43 野球の試合
ユーザー evawenisevawenis
提出日時 2020-07-09 18:10:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 214,532 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 19:37:04
合計ジャッジ時間 3,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;  cin>>n;
	vector<string>s(n); for(auto&&i:s)cin>>i;
	vector<pair<int,int>>sc(n,{0,-1}); sc.at(0).second=0;
	for(int y=0;y<n;++y){
		for(int x=0;x<n;++x){
			if(s.at(y).at(x)=='#')break;
			if(s.at(y).at(x)!='x')++sc.at(y).first;
			else ++sc.at(x).first;
		}
	}for(auto&&i:sc)cout<<i.second<<" "s<<i.first<<"\n"s;
	int ans=n+1;
	for(int i=0;i<(1<<n);++i){
		for(int j=0;j<(1<<n);++j){
			vector<pair<int,int>>tsc=sc;
			for(int y=0;y<n;++y){
				if(!(i&(1<<y)))continue;
				for(int x=0;x<n;++x){
					if(!(j&(1<<x))||x<=y||s.at(y).at(x)!='-')continue;
					++tsc.at(y).first;
					--tsc.at(x).first;
				}
			}
			stable_sort(tsc.rbegin(),tsc.rend());
			int tans=n+1;
			for(int k=0,fix=1;k<n;++k){
				if(k>0&&tsc.at(k)==tsc.at(k-1))--fix;
				if(tsc.at(k).second==0){
					tans=k+fix;
					break;
				}
			}
			ans=min(ans,tans);
		}
	}
	cout<<ans<<"\n"s;
}
0