結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2015-06-19 01:16:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 937 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 62,708 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 03:48:14 |
合計ジャッジ時間 | 900 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
ソースコード
#include <iostream>#include <algorithm>#include <sstream>#include <numeric>using namespace std;int main(int argc, char *argv[]) {string s;getline(cin, s);stringstream sa(s);int N;sa >> N;string res[6];for (int i = 0; i < N; ++i) {getline(cin, res[i]);}int ans = N;int score = count_if(res[0].begin(), res[0].end(), [](char c) -> bool { return c == 'o' || c == '-'; });int m = 1 << ((N - 1) * (N - 2) / 2);for (int b = 0; b < m; ++b) {int a = 1;int r[6][6] = {};int pos = 0;for (int i = 1; i < N; ++i) {r[i][0] = res[i][0] == 'o';for (int j = i + 1; j < N; ++j) {if (res[i][j] == '-') {r[i][j] = ((1 << pos) & b) != 0;r[j][i] = r[i][j] ^ 1;} else {r[i][j] = res[i][j] == 'o';r[j][i] = res[j][i] == 'o';}++pos;}int t = accumulate(r[i], r[i] + N, 0);a += t > score;}ans = min(ans, a);}cout << ans << endl;return 0;}