結果
| 問題 | No.43 野球の試合 |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-09-28 23:37:30 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 5,000 ms |
| + 303µs | |
| コード長 | 1,334 bytes |
| 記録 | |
| コンパイル時間 | 5,660 ms |
| コンパイル使用メモリ | 395,248 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-09-28 23:37:41 |
| 合計ジャッジ時間 | 6,747 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#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 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;
}
C