11580

#include <stdio.h>
#include <stdlib.h>

#define LEN 2002

int main(void){
    // 테스트 케이스 입력
    int test_case = 0;
    scanf("%d", &test_case);

    // 명령 입력
    char *command = (char *)malloc(sizeof(char)*(test_case+1));
    scanf("%s", command);

    // 좌표계 생성
    int arr[LEN][LEN] = {0};
    int x = LEN/2, y = LEN/2;
    int count = 1;

    // 0,0 은 1로 바꾸기
    arr[x][y] = 1;
    for(int i = 0; i < test_case; i++){
        char com = command[i];
        switch (com)
        {
        case 'E': // 동
            x++;
            break;
        case 'W': // 서
            x--;
            break;
        case 'S': // 남
            y--;
            break;
        case 'N': // 북
            y++;
            break;
        }
        
        if(!arr[x][y]){ // 만약 0일 경우 1로 바꾸고 count
            arr[x][y] = 1;
            count++;
        }
    }

    // 발자국의 수 출력
    printf("%d", count);

    return 0;
}

+ Recent posts