結果

問題 No.43 野球の試合
ユーザー BantakoBantako
提出日時 2018-06-07 00:35:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,305 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 176,280 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 22:56:40
合計ジャッジ時間 2,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,0,N)cin >> S[i];

    int cnt = 0;
    vector< P > V;
    rep(i,0,N)rep(j,i,N){
        if(S[i][j] == '-'){
            cnt++;
            V.push_back(P(i,j));
        }
    }
    int mini = INF;
    rep(i,0,1 << cnt){
        rep(j,0,cnt){
            bool flag = i & (1 << j);
            
            int x = V[j].second,y = V[j].first;
            S[y][x] = "ox"[flag];
            S[x][y] = "xo"[flag];
        
        }
    /*
    cout  << endl;
    rep(j,0,N)cout << S[j] << endl;
    cout  << endl;
    */
        vector< P > win(N);
        rep(j,0,N)win[j].second = j;

        //for(auto p:win)cout << p.first << " " << p.second << endl;

        rep(j,0,N)rep(k,0,N){
            if(S[j][k] == 'o')win[j].first ++;
        }
        sort(win.rbegin(), win.rend());
        int rank = 1,num = win[0].first;
        rep(j,0,N){
            if(num != win[j].first){
                num = win[j].first;
                rank++;
            }
            if(win[j].second == 0)mini = min(mini, rank);
        }
    }
    cout << mini << endl;
}
0