結果

問題 No.43 野球の試合
ユーザー goodbatongoodbaton
提出日時 2015-08-04 21:10:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,419 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 80,716 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 01:09:14
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 10001

int n,point[6];
char s[6][8];
vector<pair<int,int> > vec;

int dfs(int h){
    int a,b;
    
    if(h==vec.size()){
        int rank=1;
        vector<int> result;
        for(int i=1;i<n;i++)
            result.push_back(point[i]);
        
        sort(result.begin(),result.end());
        
        for(int i=1;i<n;i++){
            if(point[i]>point[0] && point[i]!=point[i-1])
                rank++;
        }
        
        return rank;
    }
    
    point[vec[h].first]++;
    a = dfs(h+1);
    point[vec[h].first]--;
    point[vec[h].second]++;
    b = dfs(h+1);
    point[vec[h].second]--;
    
    return min(a,b);
}

int main(){
    
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
        scanf("%s",s[i]);
    
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i][j]=='-'){
                vec.push_back({i,j});
            }else if(s[i][j]=='o'){
                point[i]++;
            }else{
                point[j]++;
            }
        }
    }
    
    printf("%d\n",dfs(0));
    
    return 0;
}
0