結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-09 18:58:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 865 bytes |
| コンパイル時間 | 2,346 ms |
| コンパイル使用メモリ | 206,128 KB |
| 最終ジャッジ日時 | 2025-01-11 17:11:06 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0),ios::sync_with_stdio(false);
int n; cin>>n;
vector<string>s(n); for(auto&&i:s)cin>>i;
vector<pair<int,int>>a,sc(n,{0,-1}); sc.at(0).second=0;
for(int y=0;y<n;++y){
for(int x=0;x<y;++x){
if(s.at(y).at(x)!='x'){
if(s.at(y).at(x)=='-')a.push_back({y,x});
++sc.at(y).first;
}
else ++sc.at(x).first;
}
}
int ans=n+1;
for(int i=0;i<(1<<a.size());++i){
vector<pair<int,int>>tsc=sc;
for(int j=0;j<a.size();++j){
if(!(i&(1<<j)))continue;
int y=a.at(j).first,x=a.at(j).second;
++tsc.at(x).first,--tsc.at(y).first;
}
sort(tsc.rbegin(),tsc.rend());
int tans=n+1;
for(int j=0,fix=1;j<n;++j){
if(tsc.at(j).second==-1){
if(j>0&&tsc.at(j).first==tsc.at(j-1).first)--fix;
continue;
}
tans=j+fix;
}
ans=min(ans,tans);
}
cout<<ans<<"\n"s;
}