結果
問題 |
No.43 野球の試合
|
ユーザー |
![]() |
提出日時 | 2021-10-21 17:49:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 4,327 ms |
コンパイル使用メモリ | 256,184 KB |
最終ジャッジ日時 | 2025-01-25 02:24:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000 int main(){ int N; cin>>N; vector<string> S(N); rep(i,N){ cin>>S[i]; } vector<pair<int,int>> p; rep(i,N){ for(int j=i+1;j<N;j++){ p.emplace_back(i,j); } } int ans = Inf; rep(i,1<<p.size()){ bool f = true; vector<int> win(N,0); rep(j,p.size()){ char c = S[p[j].first][p[j].second]; if(c=='o'&&((i>>j)&1)==0)f = false; if(c=='x'&&((i>>j)&1)==1)f = false; if((i>>j)&1){ win[p[j].first]++; } else{ win[p[j].second]++; } } if(!f)continue; auto ww = win; sort(ww.begin(),ww.end()); ww.erase(unique(ww.begin(),ww.end()),ww.end()); ans = min(ans,(int)distance(lower_bound(ww.begin(),ww.end(),win[0]),ww.end())); } cout<<ans<<endl; return 0; }