結果

問題 No.43 野球の試合
ユーザー kpinkcatkpinkcat
提出日時 2023-10-09 23:25:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,636 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 119,140 KB
実行使用メモリ 10,328 KB
最終ジャッジ日時 2023-10-09 23:25:58
合計ジャッジ時間 2,244 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    int n, mrank = 10;
    cin >> n;
    vector<string> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];
    deque<vector<string>> dq;
    dq.push_back(l);
    while (!dq.empty()) {
        vector<string> tmp = dq.front();
        vector<int> pt;
        dq.pop_front();
        int mypt;
        bool nfill = false;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (tmp[i][j] == '-'){
                    tmp[i][j] = 'o';
                    tmp[j][i] = 'x';
                    dq.push_back(tmp);
                    tmp[i][j] = 'x';
                    tmp[j][i] = 'o';
                    dq.push_back(tmp);
                    nfill = true;
                    break;
                }
            }
            if (nfill) break;
        }
        if (nfill) continue;
        for (int i = 0; i < n; i++){
            int cnt = 0;
            for (int j = 0; j < n; j++){
                if (tmp[i][j] == 'o') cnt++;
            }
            pt.push_back(cnt);
        }
        mypt = pt[0];
        sort(pt.begin(), pt.end(), greater());
        int rank = 1, maxpt = pt[0];
        for (int i = 0; i < n; i++){
            if (maxpt > pt[i]){
                rank++;
                maxpt = pt[i];
            }
            if (mypt == pt[i]){
                if (mrank > rank) mrank = rank;
            }
        }
    }
    cout << mrank << endl;
}
0