結果
| 問題 | No.43 野球の試合 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-12-09 06:25:11 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 5,000 ms | 
| コード長 | 1,479 bytes | 
| コンパイル時間 | 1,956 ms | 
| コンパイル使用メモリ | 177,020 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-28 16:10:16 | 
| 合計ジャッジ時間 | 2,407 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
コンパイルメッセージ
main.cpp: In function 'int calc_team0_place(const std::vector<std::__cxx11::basic_string<char> >&)':
main.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
int calc_team0_place(const vector<string> &s)
{
    int n=s.size();
    vector<int> win(n,0);
    rep(i,n)
    {
        rep(j,n) win[i]+=(s[i][j]=='o');
    }
    vector<int> sorted_win(win);
    sort(all(sorted_win),greater<int>());
    sorted_win.erase(unique(all(sorted_win)), sorted_win.end());
    rep(i,sorted_win.size())
    {
        if(sorted_win[i] == win[0]) return i+1;
    }
}
int main()
{
    int n;
    cin >>n;
    vector<string> s(n);
    rep(i,n) cin >>s[i];
    int r=0;
    rep(i,n)for(int j=i+1; j<n; ++j) r+=(s[i][j]=='-');
    int ans=6;
    if(r==0) ans=calc_team0_place(s);
    else
    {
        rep(mask,1<<r)
        {
            vector<string> t(s);
            int ct=0;
            rep(i,n)for(int j=i+1; j<n; ++j)if(t[i][j]=='-')
            {
                if(mask>>ct&1)
                {
                    t[i][j]='o';
                    t[j][i]='x';
                }
                else
                {
                    t[i][j]='x';
                    t[j][i]='o';
                }
                ++ct;
            }
            ans = min(ans, calc_team0_place(t));
        }
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        