結果
| 問題 | No.43 野球の試合 |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-24 05:22:20 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 5,000 ms |
| + 595µs | |
| コード長 | 1,140 bytes |
| 記録 | |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 69,376 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-13 09:53:10 |
| 合計ジャッジ時間 | 1,936 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 |
ソースコード
// ナニソレイミワカンナイ
#include <cstdio>
#include <vector>
#include <algorithm>
int N;
char result[6][6];
int win[6];
int rec(int x, int y){
if(y == N-1){
std::vector<int> v(win, win+N);
std::sort(v.begin(), v.end());
v.erase(std::unique(v.begin(), v.end()), v.end());
return v.size() - (std::lower_bound(v.begin(), v.end(), win[0]) - v.begin());
}
int nx, ny;
if(x+1 == N){
ny = y + 1;
nx = ny + 1;
}else{
ny = y;
nx = x + 1;
}
int res = N;
if(result[y][x] == '-'){
win[x] += 1;
res = std::min(res, rec(nx, ny));
win[x] -= 1;
win[y] += 1;
res = std::min(res, rec(nx, ny));
win[y] -= 1;
}else{
res = std::min(res, rec(nx, ny));
}
return res;
}
int main(){
scanf("%d", &N);
for(int i=0;i<N;i++){
scanf("%*c");
for(int j=0;j<N;j++){
scanf("%c", &result[i][j]);
if(result[i][j] == 'o'){win[i] += 1;}
}
}
printf("%d\n", rec(1, 0));
}
tottoripaper