結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2018-06-24 15:44:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 924 ms |
コンパイル使用メモリ | 99,428 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 22:30:59 |
合計ジャッジ時間 | 1,514 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
#include <cstdio>#include <cstdlib>#include <cmath>#include <climits>#include <cfloat>#include <map>#include <utility>#include <set>#include <iostream>#include <memory>#include <string>#include <vector>#include <algorithm>#include <functional>#include <sstream>#include <complex>#include <stack>#include <queue>#include <iomanip>using namespace std;#define INF 1e9#define PI acos(-1)typedef long long ll;int main() {int n; cin >> n;vector<string> str(n);for (int i = 0; i < n; i++)cin >> str[i];vector<int>a, b;vector<int>win(n);for (int i = 0; i < n; i++)for (int j = 0; j < i; j++) {if (str[i][j] == '-') {a.push_back(i); b.push_back(j);}else if (str[i][j] == 'o')win[i]++;else win[j]++;}int ans = n;for (int i = 0; i < (1 << a.size()); i++) {//未対戦の勝敗全列挙vector<int> wt(win);for (int j = 0; j < a.size(); j++) {if ((i >> j) % 2)wt[a[j]]++;else wt[b[j]]++;}for (int k = 0; k < n; k++)wt[k] = wt[k] * n + k;sort(wt.begin(), wt.end());reverse(wt.begin(), wt.end());int place = 0, f = -1;for (int l = 0; l < n; l++) {int wnum = wt[l] / n;int team = wt[l] % n;if (f != wnum) {f = wnum; place++;}if (team == 0)ans = min(place, ans);}}cout << ans << endl;return 0;}