結果

問題 No.43 野球の試合
ユーザー matsukin1111matsukin1111
提出日時 2019-04-08 11:31:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,580 bytes
コンパイル時間 1,022 ms
コンパイル使用メモリ 103,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 15:39:47
合計ジャッジ時間 1,782 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 19 ms
4,376 KB
testcase_07 AC 23 ms
4,376 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 18 ms
4,380 KB
testcase_10 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int check(std::vector<std::__cxx11::basic_string<char> >)’ 内:
main.cpp:57:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   57 | }
      | ^
main.cpp:55:17: 警告: ‘st’ may be used uninitialized [-Wmaybe-uninitialized]
   55 |                 if (u[i] == st)return i + 1;
      |                 ^~
main.cpp:40:13: 備考: ‘st’ はここで定義されています
   40 |         int st;
      |             ^~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

vector<string>s;
int n;
int check(vector<string>temp) {
	vector<int>u;
	int st;
	rep(i, 0, n){
		int point = 0;
		rep(j, 0, n) {
			if (temp[i][j] == 'o')point++;
		}
		u.pb(point);
		if (i == 0)st = point;
	}
	sort(all(u));
	u.erase(unique(all(u)),u.end());
	sort(all(u));
	reverse(all(u));

	rep(i,0,u.size()) {
		if (u[i] == st)return i + 1;
	}
}

int main() {
	cin >> n;
	rep(i, 0, n) {
		string temp;
		cin >> temp;
		s.pb(temp);
	}
	
	int ans = 101010;
	rep(msk, 0, 1 << n * (n - 1) / 2) {
		vector<string>temp;
		rep(i, 0, n)temp.pb(s[i]);

		int cnt = 0;
		rep(i, 0, n)rep(j, 0, n) {
			if (i < j) {
				if (s[i][j] == '-') {
					int c = (1 << cnt) & msk;
					temp[i][j] = c ? 'o' : 'x';
					temp[j][i] = c ? 'x' : 'o';
				}
				cnt++;
			}
		}
		ans = min(check(temp), ans);
	}
	cout << ans << endl;
	return 0;
}
0