結果
問題 |
No.43 野球の試合
|
ユーザー |
|
提出日時 | 2018-07-23 17:55:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,370 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 72,864 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-29 20:39:21 |
合計ジャッジ時間 | 1,227 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
ソースコード
#include<iostream> #include<set> 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++; set<int> score; score.insert(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.insert(tmp); } int pos = 1; for(set<int>::reverse_iterator it = score.rbegin(); it != score.rend(); it++){ if(*it == zero){ ans = min(ans, pos); break; } pos++; } } } 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; }