[swexpert] 7272. 안경이 없어 (JAVA, D3)
728x90
반응형
import java.util.Scanner;
public class Solution {
static int t;
static String a="CEFGHIJKLMNSTUVWXYZ";
static String b="ADOPQR";
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
t=sc.nextInt();
for (int tc = 1; tc <=t; tc++) {
String x=sc.next();
String y=sc.next();
boolean diff=false;
if(x.length()!=y.length()) {
diff=true;
}else {
for (int i = 0; i < x.length(); i++) {
if(x.charAt(i)==y.charAt(i))continue;
if(!check(x.charAt(i),y.charAt(i))) {
diff=true;
break;
}
}
}
System.out.printf("#%d %S\n",tc,diff?"DIFF":"SAME");
}
}
private static boolean check(char c, char d) {
if(a.indexOf(c)!=-1) {
if(a.indexOf(d)==-1)return false;
}
if(b.indexOf(c)!=-1) {
if(b.indexOf(d)==-1)return false;
}
if(c=='B' && d!='B')return false;
return true;
}
}
728x90
반응형
TAGS.