結果
| 問題 | No.43 野球の試合 |
| コンテスト | |
| ユーザー |
matsukin1111
|
| 提出日時 | 2019-04-08 11:31:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 5,000 ms |
| コード長 | 1,580 bytes |
| 記録 | |
| コンパイル時間 | 1,086 ms |
| コンパイル使用メモリ | 105,664 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-01 22:50:27 |
| 合計ジャッジ時間 | 1,720 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function 'int check(std::vector<std::__cxx11::basic_string<char> >)':
main.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^
main.cpp:55:17: warning: 'st' may be used uninitialized [-Wmaybe-uninitialized]
55 | if (u[i] == st)return i + 1;
| ^~
main.cpp:40:13: note: 'st' was declared here
40 | int st;
| ^~
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
vector<string>s;
int n;
int check(vector<string>temp) {
vector<int>u;
int st;
rep(i, 0, n){
int point = 0;
rep(j, 0, n) {
if (temp[i][j] == 'o')point++;
}
u.pb(point);
if (i == 0)st = point;
}
sort(all(u));
u.erase(unique(all(u)),u.end());
sort(all(u));
reverse(all(u));
rep(i,0,u.size()) {
if (u[i] == st)return i + 1;
}
}
int main() {
cin >> n;
rep(i, 0, n) {
string temp;
cin >> temp;
s.pb(temp);
}
int ans = 101010;
rep(msk, 0, 1 << n * (n - 1) / 2) {
vector<string>temp;
rep(i, 0, n)temp.pb(s[i]);
int cnt = 0;
rep(i, 0, n)rep(j, 0, n) {
if (i < j) {
if (s[i][j] == '-') {
int c = (1 << cnt) & msk;
temp[i][j] = c ? 'o' : 'x';
temp[j][i] = c ? 'x' : 'o';
}
cnt++;
}
}
ans = min(check(temp), ans);
}
cout << ans << endl;
return 0;
}
matsukin1111