별집사의 IT세상

NORMAL 김씨만 행복한 세상 본문

IT/코드그라운드

NORMAL 김씨만 행복한 세상

별집사 2017. 4. 5. 17:56
반응형

코드그라운드 노말 44번문제


입력




출력



관리자를 1, 2 대신 0, 1로 지정하고(코딩의 편의를 위해) 초기에 모든 영역의 관리자를 0으로 초기화 해준다.


인접하는 지역 번호를 받으면서 인접 지역의 관리자를 반대로 저장하였다 ( 0 = !1, 1 = !0)


모든 경우의 인접 지역 관리자를 조사하여 같은 관리자가 있는 경우 result를 0으로 변경하고 종료한다.


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
<p>#include </p><stdio.h>
#include <stdlib.h>
int main(void) {
 
    setbuf(stdout, NULL);
 
    int TC;
    int test_case;
    int N, M; // 200, 1000
    int start[1000];
    int end[1000];
    int num[201];
    int i;
    int result;
    scanf("%d", &TC);
    for (test_case = 1; test_case <= TC; test_case++) {
        result = 1;
        scanf("%d %d", &N, &M);
        for (i = 0; i < 201; i++) {
            num[i] = 0;
        }
        for (i = 0; i < M; i++) {
            scanf("%d %d", &start[i],&end[i]);
            num[end[i]] = !num[start[i]];
        }
        for (i = 0; i < M; i++) {
            if (num[start[i]] == num[end[i]]) {
                result = 0;
                break;
            }
        }
        printf("Case #%d\n", test_case);
        printf("%d\n", result);
 
    }
 
    return 0;
}
</stdlib.h></stdio.h>
반응형

'IT > 코드그라운드' 카테고리의 다른 글

NORMAL2 수강신청  (0) 2017.04.12
NORMAL2 새로운 방  (0) 2017.04.11
EASY 시험공부  (0) 2017.02.20
Comments