結果

問題 No.43 野球の試合
ユーザー face4face4
提出日時 2018-07-23 18:17:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,434 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 72,684 KB
実行使用メモリ 7,564 KB
最終ジャッジ日時 2023-08-28 16:57:31
合計ジャッジ時間 7,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;

int n;
char table[6][6] = {};
int ans = 7;

void solve(char T[6][6]){
    char TT[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;
                for(int i = 0; i < 6; i++){
                    for(int j = 0; j < 6; j++){
                        TT[i][j] = T[i][j];
                    }
                }
                TT[i][j] = 'o'; TT[j][i] = 'x';
                solve(TT);

                TT[i][j] = 'x'; TT[j][i] = 'o';
                solve(TT);
            }
        }
    }

    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];
        }
    }

    solve(table);

    cout << ans << endl;

    return 0;
}
0