結果

問題 No.43 野球の試合
コンテスト
ユーザー C
提出日時 2026-09-28 23:25:36
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,405 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,535 ms
コンパイル使用メモリ 395,208 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-09-28 23:25:45
合計ジャッジ時間 8,684 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using pll=pair<ll,ll>;

// using mint=modint;

// template<class K,class V>
// using ordered_map=tree<K,V,less<K>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    ll N;
    cin>>N;
    vector<pll>event;
    vll win(N,0);
    for(int i=0;i<N;++i){
        string s;
        cin>>s;
        for(int j=i+1;j<N;++j){
            if(s[j]=='o')win[i]++;
            else if(s[j]=='x')win[j]++;
            else {
                if(i==0)win[0]++;
                else event.push_back({i,j});
            }
        }
    }

    ll ans=N;
    auto dfs=[&](auto&& self,int p){
        if(p==event.size()){
            vector<bool>seen(N,false);
            ll before=0;
            for(int i=1;i<N;++i){
                if(win[i]>win[0]&&!seen[win[i]])seen[win[i]]=true,before++;
            }
            ans=min(ans,before+1);
            return;
        }

        auto [a,b]=event[p];

        win[a]++;
        self(self,p+1);
        win[a]--;

        win[b]++;
        self(self,p+1);
        win[b]--;
    };

    dfs(dfs,0);

    cout<<ans<<endl;

}
0