結果
| 問題 | No.43 野球の試合 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-09-26 21:43:58 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 5,000 ms | 
| コード長 | 2,399 bytes | 
| コンパイル時間 | 740 ms | 
| コンパイル使用メモリ | 81,016 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-15 16:53:32 | 
| 合計ジャッジ時間 | 1,317 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
//#include "util.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<pair<ll, ll>, ll> Plll;
#define PI 3.14159265358979323846
#define EPS 1e-6
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define CHAR_BIT 8
#define all(x) (x).begin(), (x).end()
template <typename _KTy, typename _Ty>
ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) {
	cout << "{" << m.first << ", " << m.second << "}";
	return ostr;
}
template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
	if (v.empty()) {
		cout << "{ }";
		return ostr;
	}
	cout << "{" << v.front();
	for (auto itr = ++v.begin(); itr != v.end(); itr++) {
		cout << ", " << *itr;
	}
	cout << "}";
	return ostr;
}
template <typename _Ty>
ostream& operator << (ostream& ostr, const set<_Ty>& s) {
	if (s.empty()) {
		cout << "{ }";
		return ostr;
	}
	cout << "{" << *(s.begin());
	for (auto itr = ++s.begin(); itr != s.end(); itr++) {
		cout << ", " << *itr;
	}
	cout << "}";
	return ostr;
}
int N;
vector<char*> p, q;
int ans;
void rec(vector<string>& s, int pos)
{
	//全部埋まった
	if (pos == p.size()) {
		//順位算出
		vector<int> score(N, 0);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (s[i][j] == 'o') score[i]++;
			}
		}
		int rank = 1;
		for (int w = N - 1; w >= 0; w--) {
			if (w == score[0]) break;
			bool flag = false;
			for (int t = 1; t < N; t++) {
				if (score[t] == w) flag = true;
			}
			if (flag) rank++;
		}
		if (ans > rank) ans = rank;
		return;
	}
	*p[pos] = 'o'; *q[pos] = 'x';
	rec(s, pos + 1);
	*p[pos] = 'x'; *q[pos] = 'o';
	rec(s, pos + 1);
}
int yuki0043() 
{
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++) cin >> s[i];
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (s[i][j] != '-') continue;
			p.push_back(&s[i][j]);
			q.push_back(&s[j][i]);
		}
	}
	ans = N;
	rec(s, 0);
	cout << ans << endl;
	return 0;
}
int main()
{
	//clock_t start, end;
	//start = clock();
	yuki0043();
	//end = clock();
	//printf("%d msec.\n", end - start);
	return 0;
}
            
            
            
        