結果

問題 No.24 数当てゲーム
ユーザー itezpaceitezpace
提出日時 2016-08-19 15:48:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 2,180 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 73,884 KB
実行使用メモリ 49,508 KB
最終ジャッジ日時 2023-08-07 14:22:05
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,396 KB
testcase_01 AC 42 ms
47,116 KB
testcase_02 AC 42 ms
49,240 KB
testcase_03 AC 43 ms
49,324 KB
testcase_04 AC 43 ms
49,468 KB
testcase_05 AC 43 ms
49,252 KB
testcase_06 AC 43 ms
49,152 KB
testcase_07 AC 42 ms
49,504 KB
testcase_08 AC 43 ms
49,508 KB
testcase_09 AC 43 ms
49,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Yuki24 {
  public static void main(String[] args) throws IOException {
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    String s = br.readLine();
    int n = Integer.parseInt(s);
    ArrayList<Integer> al1 = new ArrayList<Integer>();
    ArrayList<Integer> al2 = new ArrayList<Integer>();
    int al1s;
    int al2s;
    for(int i=0; i<n; ++i){
      String s2 = br.readLine();
      String[] sa = s2.split(" ");
      String s3 = sa[4];
      al1s = al1.size();
      al2s = al2.size();
      if(s3.equals("YES")){
        if(al1.size()==0){
          for(int j=0; j<4; ++j){
            int a = Integer.parseInt(sa[j]);
            if(!al1.add(a)){
              //
            }
          }
        } else {
          for(int j=0; j<4; ++j){
            int a = Integer.parseInt(sa[j]);
            for(int k=0; k<al1s; ++k){
              int b = al1.get(k);
              if(a==b){
                if(!al1.add(a)){
                  //
                }
              }
            }
          }
          for(int k=0; k<al1s; ++k){
            al1.remove(0);
          }
        }
      } else {
        if(al2s==0){
          for(int j=0; j<4; ++j){
            int a = Integer.parseInt(sa[j]);
            if(!al2.add(a)){
              //
            }
          }
        } else {
          for(int j=0; j<4; ++j){
            int a = Integer.parseInt(sa[j]);
            if(!al2.add(a)){
              //
            }
          }
        }
      }
    }
    al1s = al1.size();
    al2s = al2.size();
    int x = 0;
    if(al1s>0){
    for(int i=0; i<al1s; ++i){
      int f = 0;
      for(int j=0; j<al2s; ++j){
        if(al1.get(i)==al2.get(j)){
          f=1;
          break;
        }
      }
      if(f==0){
        x=al1.get(i);
        break;
      }
    }
    } else {
      for(int i=0; i<=9; ++i){
        int f = 0;
        for(int j=0; j<al2s; ++j){
          if(i==al2.get(j)){
            f=1;
            break;
          }
        }
        if(f==0){
          x=i;
          break;
        }
      }
    }
    System.out.println(x);
  }
}
0