結果

問題 No.3171 Color Restoration
ユーザー msksknkn
提出日時 2025-06-14 17:41:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 3,089 ms
コンパイル使用メモリ 88,940 KB
実行使用メモリ 48,312 KB
最終ジャッジ日時 2025-06-14 17:41:09
合計ジャッジ時間 8,275 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

package no3171_color_restration;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		HashSet<String> one = new HashSet<>(Arrays.asList("gray","brown","green","cyan","blue","yellow","orange","red"));
		HashSet<String> two  =new HashSet<>(Arrays.asList("gray","green","blue","yellow","red"));
		HashSet<String> three = new HashSet<>(Arrays.asList("gray","green","cyan","blue","violet","orange","red"));
		String[] abc = new String[3];
		String[] check = {"012","021","102","120","201","210"};
		for(int i = 0;i < 3;i++) {
			abc[i] = sc.next();
		}HashSet<String> ans = new HashSet<>();
		for(int i = 0;i < 6;i++) {
			int a = check[i].charAt(0) - '0';
			int b = check[i].charAt(1) - '0';
			int c = check[i].charAt(2) - '0';
			boolean ok = true;
			if(!one.contains(abc[a]))ok = false;
			if(!two.contains(abc[b]))ok = false;
			if(!three.contains(abc[c]))ok = false;
			if(ok) {
				ans.add(abc[a] + abc[b] + abc[c]);
			}
		}System.out.print(ans.size() != 1 ? "No":"Yes");
	}
}
0