-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIloveCodeforces.java
More file actions
56 lines (40 loc) · 1.15 KB
/
IloveCodeforces.java
File metadata and controls
56 lines (40 loc) · 1.15 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class IloveCodeforces {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(in.readLine());
TreeMap<Integer, Pair> map = new TreeMap<Integer, Pair>();
for (int i = 1; i <= n; i++) {
map.put(i, new Pair(in.readLine(), 0));
}
int m = Integer.parseInt(in.readLine());
for (int i = 0; i < m; i++) {
StringTokenizer st = new StringTokenizer(in.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
Pair p = map.get(b);
map.put(a, new Pair(p.s, p.n + 1));
}
Pair p = map.get(1);
for (int i = 0; i < p.n; i++) {
out.print("I_love_");
}
out.println(p.s);
out.flush();
out.close();
}
static class Pair {
String s;
int n;
public Pair(String a, int k) {
s = a;
n = k;
}
}
}