結果
問題 | No.43 野球の試合 |
ユーザー | face4 |
提出日時 | 2018-07-23 17:43:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,361 bytes |
コンパイル時間 | 627 ms |
コンパイル使用メモリ | 74,904 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-28 15:36:23 |
合計ジャッジ時間 | 1,210 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | WA | - |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int n; char table[6][6]; int ans = 7; void solve(char T[6][6]){ bool found = false; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(T[i][j] == '-'){ found = true; T[i][j] = 'o'; T[j][i] = 'x'; solve(T); T[i][j] = 'x'; T[j][i] = 'o'; solve(T); } } } if(!found){ int zero = 0; for(int j = 0; j < n; j++) if(T[0][j] == 'o') zero++; vector<int> score; score.push_back(zero); for(int i = 1; i < n; i++){ int tmp = 0; for(int j = 0; j < n; j++) if(T[i][j] == 'o') tmp++; score.push_back(tmp); } sort(score.begin(), score.end()); for(int i = n-1; i >= 0; i--){ if(score[i] == zero){ ans = min(ans, n-i); break; } } } } int main(){ cin >> n; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> table[i][j]; } } for(int j = 0; j < n; j++){ if(table[0][j] == '-'){ table[0][j] = 'o'; table[j][0] = 'x'; } } solve(table); cout << ans << endl; return 0; }