結果

問題 No.43 野球の試合
ユーザー imulanimulan
提出日時 2016-12-09 06:25:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,479 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 175,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 03:03:46
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int calc_team0_place(const std::vector<std::__cxx11::basic_string<char> >&)’ 内:
main.cpp:30:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   30 | }
      | ^

ソースコード

diff #

#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;
}
0