結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
peroon
|
| 提出日時 | 2019-06-03 19:35:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 1,689 bytes |
| コンパイル時間 | 1,962 ms |
| コンパイル使用メモリ | 183,284 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 20:34:11 |
| 合計ジャッジ時間 | 2,499 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
const ll mod = 1e9 + 7;
const ll inf = 1e18;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N;
cin >> N;
vector<string> S(N);
FOR(i, 0, N){
cin >> S.at(i);
}
ll rank = inf;
// N==6の場合でも全ての表の埋め方は2^15通り
FOR(mask, 0, 1<<15){
ll k = -1;
map<ll, ll> mp;
// 表の右上半分のみを見る
FOR(i, 0, N){
FOR(j, i+1, N){
k++;
if(S[i][j]=='-'){
if(mask>>k & 1){
mp[i]++;
}else{
mp[j]++;
}
}
else if(S[i][j]=='o'){
mp[i]++;
}
else{
mp[j]++;
}
}
}
// 結果集計
set<ll> se;
FOR(i, 0, N){
ll win = mp[i];
se.insert(win);
}
ll player_win = mp[0];
ll dist = distance(se.begin(), se.lower_bound(player_win));
ll order = se.size() - dist;
chmin(rank, order);
}
p(rank);
return 0;
}
peroon