結果
問題 | No.24 数当てゲーム |
ユーザー | itezpace |
提出日時 | 2016-08-19 15:48:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 53 ms / 5,000 ms |
コード長 | 2,180 bytes |
コンパイル時間 | 2,520 ms |
コンパイル使用メモリ | 77,752 KB |
実行使用メモリ | 37,056 KB |
最終ジャッジ日時 | 2024-11-07 18:27:18 |
合計ジャッジ時間 | 3,480 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
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); } }