We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 00f9db2 + 2fea2ce commit 8a1bb8fCopy full SHA for 8a1bb8f
LiiNi-coder/202512/03 문자열 판별.md
@@ -0,0 +1,31 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ String S = br.readLine();
9
+ int N = Integer.parseInt(br.readLine());
10
+ Set<String> dict = new HashSet<>();
11
12
+ for(int i = 0; i < N; i++){
13
+ dict.add(br.readLine());
14
+ }
15
16
+ int size = S.length();
17
+ boolean[] dp = new boolean[size + 1];
18
+ dp[size] = true;
19
20
+ for(int i = size - 1; i >= 0; i--){
21
+ for(int j = i + 1; j <= size; j++){
22
+ if(dp[j] && dict.contains(S.substring(i, j))){
23
+ dp[i] = true;
24
+ break;
25
26
27
28
+ System.out.println(dp[0] ? 1 : 0);
29
30
+}
31
+```
0 commit comments