結果

問題 No.43 野球の試合
ユーザー fiordfiord
提出日時 2015-06-02 23:27:58
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 907 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 145,056 KB
実行使用メモリ 7,576 KB
最終ジャッジ日時 2023-09-20 18:55:26
合計ジャッジ時間 8,220 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
	}
	cout<<ans<<endl;
	return 0;
}
0