結果

問題 No.24 数当てゲーム
ユーザー kendemukendemu
提出日時 2014-11-23 16:25:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,775 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 69,428 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 22:18:27
合計ジャッジ時間 1,206 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define MAX_N 10

bool bool_table[MAX_N];
int point_table[MAX_N];
bool isInit[MAX_N];

int main(){
  int n;
  int* a;
  int* b;
  int* c;
  int* d;
  std::cin >> n;
  a =(int*)malloc(sizeof(int)*n);
  b =(int*)malloc(sizeof(int)*n);
  c =(int*)malloc(sizeof(int)*n);
  d =(int*)malloc(sizeof(int)*n);
  std::vector<std::string> r;

  std::string str;
  for(register int i = 0; i < n; i++){
    std::cin >> a[i] >> b[i] >> c[i] >> d[i] >> str;
    r.push_back(str);
  }
  for(register int i =0; i < MAX_N; i++){
    bool_table[i] = true;
    point_table[i] = 0;
    isInit[i] = false;
  }
  //init
  for(register int i = 0; i < n; i++){
    isInit[a[i]] = true;
    isInit[b[i]] = true;
    isInit[c[i]] = true;
    isInit[d[i]] = true;
   if(r[i] == "NO"){
      bool_table[a[i]] = false;
      bool_table[b[i]] = false;
      bool_table[c[i]] = false;
      bool_table[d[i]] = false;
    }
    else{
      point_table[a[i]]++;
      point_table[b[i]]++;
      point_table[c[i]]++;
      point_table[d[i]]++;
    }
  }
  int tmp = -1;
  for(register int i =0; i < MAX_N; i++){
    if(bool_table[i] && isInit[i]){
      if(point_table[i] > tmp){
        tmp = i;
      }
    }
  }
  if(tmp == -1){
    for(register int i=0; i<MAX_N; i++){
      if(bool_table[i] && isInit[i]) tmp = i;
    }
  }
  if(tmp == -1){
    int initcheck = 0;
    for(register int i=0; i<MAX_N; i++){
      if(isInit[i]) initcheck++;
    }
    if(initcheck == 9){
      for(register int i =0 ; i<MAX_N;i++){
	if(bool_table[i]) tmp = i;
      }
    }
  }
  std::cout << tmp << std::endl;
}
0