Skip to content

Commit de659c8

Browse files
authored
Create 14676.java
1 parent d86f158 commit de659c8

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

‎hyeon-uk/2021/1222~0102/14676.java‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import java.util.ArrayList;
2+
import java.util.Scanner;
3+
import java.util.Vector;
4+
5+
public class api {
6+
public static void main(String args[]){
7+
Scanner sc=new Scanner(System.in);
8+
int n,m,k;
9+
n=sc.nextInt();
10+
m=sc.nextInt();
11+
k=sc.nextInt();
12+
13+
//Graph
14+
ArrayList<ArrayList<Integer>> v=new ArrayList<>();
15+
for(int i=0;i<=n;i++) v.add(new ArrayList<>());
16+
17+
//Array
18+
int[] indeg=new int[n+1];
19+
int[] build=new int[n+1];
20+
21+
for(int i=0;i<m;i++){
22+
int x=sc.nextInt();
23+
int y=sc.nextInt();
24+
v.get(x).add(y);
25+
indeg[y]++;
26+
}
27+
28+
Boolean cheat=false;
29+
for(int i=0;i<k;i++){
30+
int op=sc.nextInt();
31+
int bNum=sc.nextInt();
32+
33+
if(op==1){
34+
if(indeg[bNum]==0){//이전에 생성되어야 할 건물들이 모두 건설되었을때
35+
build[bNum]++;//건물개수 ++
36+
if(build[bNum]==1) {//처음 건설하는 건물이면, 다음단계 건물들의 진입차수--
37+
for (int j = 0; j < v.get(bNum).size(); j++) {
38+
int next = v.get(bNum).get(j);
39+
indeg[next]--;
40+
}
41+
}
42+
}
43+
else{//이전에 생성되어야할 건물들이 지어지지않았는데 지으려했으므로 cheat=true
44+
cheat=true;
45+
}
46+
}
47+
else{
48+
if(build[bNum]>0){//생성했던 건물들이 1개이상 있을때
49+
build[bNum]--;//건물개수 --
50+
if(build[bNum]==0){//만약 해당 건물이 모두 없다면 다음단계 건물들의 진입차수++
51+
for(int j=0;j<v.get(bNum).size();j++){
52+
int next=v.get(bNum).get(j);
53+
indeg[next]++;
54+
}
55+
}
56+
}
57+
else{//생성하지도 않은 건물이 파괴되면 cheat=true
58+
cheat=true;
59+
}
60+
}
61+
}
62+
System.out.println(cheat?"Lier!":"King-God-Emperor");
63+
}
64+
}

0 commit comments

Comments
 (0)