結果

問題 No.43 野球の試合
ユーザー itezpaceitezpace
提出日時 2016-08-09 07:28:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,702 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 62,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 22:35:58
合計ジャッジ時間 1,032 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int n;
char a[6][6];

vector<int> calc(int x){
  vector<int> vc;
  int y,z;
  y=0;
  z=0;
  for(int i=0; i<n; ++i){
    if(a[x][i]=='o'){
      y++;
    } else if(a[x][i]=='-'){
      z++;
    }
  }
  vc.push_back(y);
  vc.push_back(z);
  return vc;
}

int main(){
  cin>>n;
  string s;
  for(int i=0; i<6; ++i){
    for(int j=0; j<6; ++j){
      a[i][j]='#';
    }
  }
  for(int i=0; i<n; ++i){
    cin>>s;
    for(int j=0; j<s.size(); ++j){
      a[i][j]=s[j];
    }
  }
  for(int i=0; i<n; ++i){
    if(a[0][i]=='-'){
      a[0][i]='o';
      a[i][0]='x';
    }
  }
  for(int i=1; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(a[i][j]=='-'){
        vector<int> vz,vi,vj;
        vz=calc(0);
        vi=calc(i);
        vj=calc(j);
        if(vi[0]==vz[0] && vj[0]!=vz[0]){
          a[i][j]='x';
          a[j][i]='o';
        } else if(vi[0]!=vz[0] && vj[0]==vz[0]){
          a[i][j]='o';
          a[j][i]='x';
        } else {
        if(vi[0]>vj[0]){
          a[i][j]='x';
          a[j][i]='o';
        } else if(vi[0]<vj[0]){
          a[i][j]='o';
          a[j][i]='x';
        } else {
          if(vi[1]>vj[1]){
            a[i][j]='x';
            a[j][i]='o';
          } else if(vi[1]<vj[1]){
            a[i][j]='o';
            a[j][i]='x';
          } else {
            a[i][j]='o';
            a[j][i]='x';
          }
        }
        }
      }
    }
  }
  int x;
  x=0;
  int b[n];
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(a[i][j]=='o') x++;
    }
    b[i]=x;
    x=0;
  }
  int y;
  y=1;
  for(int i=1; i<n; ++i){
    if(b[i]>b[0]) y++;
  }
  cout<<y<<endl;
  return 0;
}
0