結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-09 06:23:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,398 bytes |
| コンパイル時間 | 1,904 ms |
| コンパイル使用メモリ | 177,248 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-28 16:10:09 |
| 合計ジャッジ時間 | 2,537 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 2 |
コンパイルメッセージ
main.cpp: In function 'int calc_team0_place(const std::vector<std::__cxx11::basic_string<char> >&)':
main.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
29 | }
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
int calc_team0_place(const vector<string> &s)
{
int n=s.size();
vector<int> win(n,0);
rep(i,n)
{
rep(j,n) win[i]+=(s[i][j]=='o');
}
vector<int> sorted_win(win);
sort(all(sorted_win),greater<int>());
rep(i,n)
{
if(sorted_win[i] == win[0]) return i+1;
}
}
int main()
{
int n;
cin >>n;
vector<string> s(n);
rep(i,n) cin >>s[i];
int r=0;
rep(i,n)for(int j=i+1; j<n; ++j) r+=(s[i][j]=='-');
int ans=6;
if(r==0) ans=calc_team0_place(s);
else
{
rep(mask,1<<r)
{
vector<string> t(s);
int ct=0;
rep(i,n)for(int j=i+1; j<n; ++j)if(t[i][j]=='-')
{
if(mask>>ct&1)
{
t[i][j]='o';
t[j][i]='x';
}
else
{
t[i][j]='x';
t[j][i]='o';
}
++ct;
}
ans = min(ans, calc_team0_place(t));
}
}
cout << ans << endl;
return 0;
}