Notice
Recent Posts
Recent Comments
Link
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

코드와이

[SW Expert Academy] 안경이 없어! 본문

SW_Expert

[SW Expert Academy] 안경이 없어!

코드와이 2021. 2. 10. 10:28

 

문제링크

swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWl0ZQ8qn7UDFAXz

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

package D3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class 안경이_없어 {
	
	static String str1 = "CEFGHIJKLMNSTUVWXYZ";
	static String str2 = "ADOPQR";
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		StringBuilder sb = new StringBuilder();
		
		int T = Integer.parseInt(br.readLine());
		
		for(int tc = 1 ; tc <= T ; tc++) {
			sb.append("#" + tc +  " ");
			
			st = new StringTokenizer(br.readLine(), " ");
					
			String s1 = st.nextToken();
			String s2 = st.nextToken();
			
			if(s1.length() != s2.length()) {
				sb.append("DIFF");
			}
			else {
				boolean f = true;
				for(int i = 0 ; i < s1.length() ; i++) {
					if( ( str1.contains(s1.substring(i, i+1)) && str1.contains(s2.substring(i, i+1))) || 
							( str2.contains(s1.substring(i, i+1)) && str2.contains(s2.substring(i, i+1))) ||
							( s1.charAt(i) == 'B' && s2.charAt(i) == 'B')) {
						continue;
					}
					else {
						f = false;
						break;
					}
				}
				sb.append(f ? "SAME" : "DIFF");
			}
			System.out.println(sb);
			sb.setLength(0);
			
		}
	}
}