結果

問題 No.43 野球の試合
ユーザー fiordfiord
提出日時 2015-06-02 23:29:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 927 bytes
コンパイル時間 1,372 ms
コンパイル使用メモリ 145,536 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 18:55:29
合計ジャッジ時間 2,272 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int n;
char data[6][6];
int main(){
	cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf(" %c",&data[i][j]);
			if(data[i][j]=='-')	cnt++;
		}
	}
	int ans=7;
	bool exch[6][6];
	for(int t=0;t<(1<<cnt);t++){
		int q=0;
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				if(data[i][j]=='o'){
					exch[i][j]=true;	exch[j][i]=false;
				}
				else if(data[i][j]=='-'&&(t>>(q++))&1){
					exch[i][j]=true;	exch[j][i]=false;
				}
				else{
					exch[j][i]=true;	exch[i][j]=false;
				}
			}
		}
		int win[n];
		for(int i=0;i<n;i++){
			win[i]=0;
			for(int j=0;j<n;j++){
				if(exch[i][j])	win[i]++;
			}
		}
		bool backet[n];
		for(int i=0;i<n;i++)	backet[i]=false;
		for(int i=0;i<n;i++)	backet[win[i]]=true;
		int rank=1;
		for(int i=n-1;i>win[0];i--){
			if(backet[i])	rank++;
		}
		ans=min(ans,rank);
		if(ans==1)	break;
	}
	cout<<ans<<endl;
	return 0;
}
0