結果

問題 No.43 野球の試合
ユーザー furafura
提出日時 2020-04-14 04:12:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 203,572 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 22:49:19
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n;
string B[6];

int dfs(int i,int j){
	if(i==n){
		vector<int> cnt(n);
		rep(i,n) rep(j,n) if(B[i][j]=='o') cnt[i]++;
		int res=1;
		for(int x=n-1;x>cnt[0];x--) if(count(cnt.begin(),cnt.end(),x)>0) res++;
		return res;
	}

	if(j==n) return dfs(i+1,0);
	if(B[i][j]!='-') return dfs(i,j+1);

	int res=n;
	B[i][j]='o'; B[j][i]='x';
	res=min(res,dfs(i,j+1));
	B[i][j]='x'; B[j][i]='o';
	res=min(res,dfs(i,j+1));
	B[i][j]='-'; B[j][i]='-';
	return res;
}

int main(){
	cin>>n;
	rep(i,n) cin>>B[i];

	rep(j,n) if(B[0][j]=='-') {
		B[0][j]='o';
		B[j][0]='x';
	}

	cout<<dfs(0,0)<<'\n';

	return 0;
}
0