๋ฐ์ํ
๋ฌธ์ (Silver 3)
https://www.acmicpc.net/problem/9996
ํ์ด
๋ฌธ์ ๊ฐ ์ด๋ ต์ง๋ ์์ง๋ง ์ดํด๋ฅผ ์ ํด์ผํ๋ ๋ฌธ์ !
substring์ผ๋ก ๋๋๋์ ๋ฐ๋ก๊ฐ ๋ง์ผ๋ ์ด๋ฅผ ์ ์ฒดํฌํด์ฃผ์ด์ผ ํ๋ค.
์ฝ๋
๋๋ณด๊ธฐ
package implement;
import java.io.*;
import java.util.*;
public class Main_9996_ํ๊ตญ์ด๊ทธ๋ฆฌ์ธ๋์๋ฒ์์ ์ํ์ง {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
String[] pattern = br.readLine().split("\\*");
for(int i =0 ; i < N ; i++){
String file = br.readLine();
if(file.length() < pattern[0].length()+pattern[1].length()){ // ๋ฌธ์ ํจํด ๋ณด๋ค ๋ฌธ์์ด์ด ๋ ์งง์ ๋
sb.append("NE\n"); continue;
}
String fileF = file.substring(0,pattern[0].length());
String remFile = file.substring(pattern[0].length(), file.length());
String fileB = remFile.substring(remFile.length()-pattern[1].length(),remFile.length());
if(fileF.equals(pattern[0]) && fileB.equals(pattern[1])){
sb.append("DA\n");
}else
sb.append("NE\n");
}
System.out.println(sb.toString());
}
}
๋ฐ์ํ
'๐ ์๊ณ ๋ฆฌ์ฆ > Implementation' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 1253๋ฒ: ์ข๋ค (Java) (0) | 2022.04.13 |
---|---|
[๋ฐฑ์ค] 16639๋ฒ: ๊ดํธ ์ถ๊ฐํ๊ธฐ 3 (0) | 2022.03.29 |
[๋ฐฑ์ค]11660๋ฒ: ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (Java) (0) | 2022.03.16 |
[๋ฐฑ์ค] 18222๋ฒ ํฌ์-๋ชจ์ค ๋ฌธ์์ด ( Java ) (0) | 2022.02.16 |
[๋ฐฑ์ค] 1032๋ฒ ๋ช ๋ นํ๋กฌํํธ (Java) (0) | 2022.02.16 |