-
Notifications
You must be signed in to change notification settings - Fork 1
/
TrieMatchingExtended.java
66 lines (56 loc) · 1.37 KB
/
TrieMatchingExtended.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.io.*;
import java.util.*;
class Node
{
public static final int Letters = 4;
public static final int NA = -1;
public int next [];
public boolean patternEnd;
Node ()
{
next = new int [Letters];
Arrays.fill (next, NA);
patternEnd = false;
}
}
public class TrieMatchingExtended implements Runnable {
int letterToIndex (char letter)
{
switch (letter)
{
case 'A': return 0;
case 'C': return 1;
case 'G': return 2;
case 'T': return 3;
default: assert (false); return Node.NA;
}
}
List <Integer> solve (String text, int n, List <String> patterns) {
List <Integer> result = new ArrayList <Integer> ();
// write your code here
return result;
}
public void run () {
try {
BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
String text = in.readLine ();
int n = Integer.parseInt (in.readLine ());
List <String> patterns = new ArrayList <String> ();
for (int i = 0; i < n; i++) {
patterns.add (in.readLine ());
}
List <Integer> ans = solve (text, n, patterns);
for (int j = 0; j < ans.size (); j++) {
System.out.print ("" + ans.get (j));
System.out.print (j + 1 < ans.size () ? " " : "\n");
}
}
catch (Throwable e) {
e.printStackTrace ();
System.exit (1);
}
}
public static void main (String [] args) {
new Thread (new TrieMatchingExtended ()).start ();
}
}