File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments