結果

問題 No.43 野球の試合
ユーザー hayaDhayaD
提出日時 2018-04-21 19:16:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 1,373 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 78,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 12:23:01
合計ジャッジ時間 1,275 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int x[6][6];

int rankTeam(int N){
	int win[N];
	FOR(i,0,N){
		win[i] = 0;
		FOR(j,0,N){
			if (i < j){
				if (x[i][j] == 1) win[i]++;
			}else if(i > j){
				if (x[j][i] == 0) win[i]++;
			}
		}
	}

	int team = win[0];
	sort(win,win+N);
	int ret = 1;
	for(int i = N-1;i >= 0;i--){
		if(team == win[i]) break;
		else{
			if(i == N-1) ret++;
			else if(win[i] != win[i+1]) ret++;
		}
	}
	return ret;
}

int main(){
	int b = 0;
	int ax[36] = {0};
	int bx[36] = {0};
	int N;
	int ret = 6;
	cin >> N;

	FOR(i,0,N){
		string s;
		cin >> s;
		FOR(j,i+1,N){
			if (s[j] == 'o') x[i][j] = 1;
			else if(s[j] == 'x') x[i][j] = 0;
			else {
				x[i][j] = 0;
				ax[b] = i;
				bx[b] = j;
				b++;
			}
		}
	}

	for (int i = 0;i < (1 << b);i++){
		for (int j = b-1; j>=0 ;j--){
			if(i >> j & 1){
				x[ax[j]][bx[j]] = 1;
			}else{
				x[ax[j]][bx[j]] = 0;
			}
		}

		int rr = rankTeam(N);
		if ( ret > rr) ret = rr;
	}
	cout << ret << endl;
	return 0;
}
0