結果

問題 No.43 野球の試合
ユーザー myanta
提出日時 2017-05-05 14:20:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,390 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 44,544 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 08:41:59
合計ジャッジ時間 1,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:105:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  105 |                         scanf("%s", buf);
      |                         ~~~~~^~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include<cstdio>
#include<vector>
using namespace std;
using vi=vector<int>;
using vvi=vector<vector<int> >;
struct count_t
{
int win, lose;
};
int count(vvi& s)
{
int n=s.size();
vi c(n);
int rank=0;
vi b(n);
for(int y=0;y<n;y++)
{
for(int x=0;x<n;x++)
{
if(s[y][x]=='o') c[y]++;
}
b[c[y]]++;
}
for(int i=n-1;i>=0;i--)
{
if(b[i]) rank++;
if(c[0]==i) return rank;
}
return 999;
}
int min_u(int& m, int v)
{
if(m>v)
{
m=v;
return 1;
}
return 0;
}
void vvi_dump(const vvi& s)
{
unsigned x, y;
for(y=0;y<s.size();y++)
{
for(x=0;x<s[y].size();x++) printf("%c ", s[y][x]);
printf("\n");
}
printf("\n");
}
int solve(vvi& w)
{
int n=w.size();
int ret=n;
for(int y=1;y<n;y++)
{
for(int x=y+1;x<n;x++)
{
if(w[y][x]!='-') continue;
w[y][x]='o', w[x][y]='x';
min_u(ret, solve(w));
w[y][x]='x', w[x][y]='o';
min_u(ret, solve(w));
w[y][x]='-', w[x][y]='-';
return ret;
}
}
// vvi_dump(w);
return count(w);
}
int main(void)
{
vvi s;
vector<count_t> c;
int n;
int x, y;
while(scanf("%d", &n)==1)
{
c.resize(n);
s.resize(n);
for(y=0;y<n;y++)
{
char buf[6+2];
s[y].resize(n);
scanf("%s", buf);
for(x=0;x<n;x++)
{
s[y][x]=buf[x];
}
}
for(x=0;x<n;x++)
{
if(s[0][x]=='-')
{
s[0][x]='o';
s[x][0]='x';
}
}
printf("%d\n", solve(s));
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0