結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-08-04 21:10:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 1,419 bytes |
| コンパイル時間 | 757 ms |
| コンパイル使用メモリ | 81,036 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 01:19:34 |
| 合計ジャッジ時間 | 1,338 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:59:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
59 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:62:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%s",s[i]);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL
#define SIZE 10001
int n,point[6];
char s[6][8];
vector<pair<int,int> > vec;
int dfs(int h){
int a,b;
if(h==vec.size()){
int rank=1;
vector<int> result;
for(int i=1;i<n;i++)
result.push_back(point[i]);
sort(result.begin(),result.end());
for(int i=1;i<n;i++){
if(point[i]>point[0] && point[i]!=point[i-1])
rank++;
}
return rank;
}
point[vec[h].first]++;
a = dfs(h+1);
point[vec[h].first]--;
point[vec[h].second]++;
b = dfs(h+1);
point[vec[h].second]--;
return min(a,b);
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%s",s[i]);
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(s[i][j]=='-'){
vec.push_back({i,j});
}else if(s[i][j]=='o'){
point[i]++;
}else{
point[j]++;
}
}
}
printf("%d\n",dfs(0));
return 0;
}
goodbaton