結果
問題 | No.43 野球の試合 |
ユーザー | iqueue02 |
提出日時 | 2020-07-29 00:56:06 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 2,166 ms |
コンパイル使用メモリ | 207,112 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-11 06:57:24 |
合計ジャッジ時間 | 3,084 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 8 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair<int,int> P; int main() { int n; cin >> n; vector<string> s(n); rep(i,n) cin >> s[i]; vector<int> a; vector<int> cost(n, 0); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (s[i][j] == '-') a.emplace_back(i * n + j); if (s[i][j] == 'o') cost[i]--; if (s[i][j] == 'x') cost[j]--; } } int m = a.size(); int res = 1000; for (int bit = 0; bit < (1 << m); bit++) { auto tmp = cost; for (int i = 0; i < m; i++) { int u = a[i] / n, v = a[i] % n; if (bit & (1 << i)) tmp[u]--; else tmp[v]--; } int cur = tmp[0]; sort(tmp.begin(), tmp.end()); tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end()); int x = lower_bound(tmp.begin(), tmp.end(), cur) - tmp.begin(); x++; res = min(res, x); } cout << res << endl; return 0; }