結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
not_522
|
| 提出日時 | 2015-07-17 09:05:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 761 bytes |
| コンパイル時間 | 1,215 ms |
| コンパイル使用メモリ | 166,768 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 08:21:46 |
| 合計ジャッジ時間 | 1,822 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int solve(vector<string>& s, int i, int j) {
int n = s.size();
if (i == n) {
for (int y = 0; y < n; ++y) {
for (int x = y + 1; x < n; ++x) s[y][x] = s[x][y] ^ 'o' ^ 'x';
}
set<int> w;
for (const auto& i : s) w.insert(count(i.begin(), i.end(), 'x'));
return distance(w.begin(), w.find(count(s[0].begin(), s[0].end(), 'x'))) + 1;
}
if (i == j) return solve(s, i + 1, 0);
if (s[i][j] != '-') return solve(s, i, j + 1);
s[i][j] = 'o';
int res = solve(s, i, j + 1);
s[i][j] = 'x';
res = min(res, solve(s, i, j + 1));
s[i][j] = '-';
return res;
}
int main() {
int n;
cin >> n;
vector<string> s(n);
for (auto& i : s) cin >> i;
cout << solve(s, 0, 0) << endl;
}
not_522