답안 #594079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594079 2022-07-12T05:03:36 Z 박상훈(#8431) 영역 (JOI16_ho_t4) C++17
15 / 100
76 ms 4976 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
set<pair<int, int>> visited, made;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1}, cc[1234];
char s[100100];

bool ok(int x, int y){
    return visited.find(make_pair(x, y))!=visited.end();
}

int _make(int x, int y){
    if (made.find(make_pair(x, y))!=made.end()) return 0;
    if (ok(x, y) && ok(x+1, y) && ok(x, y+1) && ok(x+1, y+1)){
        made.emplace(x, y);
        return 1;
    }
    return 0;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    scanf("%s", s+1);

    cc['E'] = 0, cc['S'] = 1, cc['W'] = 2, cc['N'] = 3;

    int prv = 1e9, x = 0, y = 0, c = 0;
    ll ans = 0;

    visited.emplace(0, 0);
    while(k){
        int cnt = 0;
        for (int i=1;i<=n;i++){
            x += dx[cc[s[i]]], y += dy[cc[s[i]]];
            visited.emplace(x, y);
            cnt += _make(x, y);
            cnt += _make(x, y-1);
            cnt += _make(x-1, y);
            cnt += _make(x-1, y-1);
        }
        ans += cnt;
        --k;
        ++c;
        if (c>20) break;
        //if (prv==cnt) break;
        prv = cnt;
        //printf("%d\n", cnt);
    }

    ans += (ll)prv * k;
    printf("%lld\n", ans);
    return 0;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:36:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   36 |             x += dx[cc[s[i]]], y += dy[cc[s[i]]];
      |                        ~~~^
2016_ho_t4.cpp:36:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   36 |             x += dx[cc[s[i]]], y += dy[cc[s[i]]];
      |                                           ~~~^
2016_ho_t4.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t4.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%s", s+1);
      |     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 4 ms 356 KB Output is correct
28 Correct 9 ms 596 KB Output is correct
29 Correct 29 ms 1364 KB Output is correct
30 Correct 39 ms 1556 KB Output is correct
31 Correct 62 ms 4504 KB Output is correct
32 Correct 52 ms 1940 KB Output is correct
33 Correct 58 ms 2316 KB Output is correct
34 Correct 63 ms 2396 KB Output is correct
35 Correct 56 ms 2212 KB Output is correct
36 Correct 54 ms 2060 KB Output is correct
37 Correct 54 ms 2260 KB Output is correct
38 Correct 56 ms 2184 KB Output is correct
39 Correct 72 ms 2252 KB Output is correct
40 Correct 57 ms 2020 KB Output is correct
41 Correct 52 ms 1872 KB Output is correct
42 Correct 46 ms 1644 KB Output is correct
43 Correct 58 ms 2380 KB Output is correct
44 Correct 56 ms 2160 KB Output is correct
45 Correct 50 ms 1828 KB Output is correct
46 Correct 73 ms 2616 KB Output is correct
47 Correct 76 ms 2708 KB Output is correct
48 Correct 66 ms 4968 KB Output is correct
49 Correct 67 ms 4972 KB Output is correct
50 Correct 69 ms 4976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Incorrect 1 ms 212 KB Output isn't correct
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 4 ms 356 KB Output is correct
28 Correct 9 ms 596 KB Output is correct
29 Correct 29 ms 1364 KB Output is correct
30 Correct 39 ms 1556 KB Output is correct
31 Correct 62 ms 4504 KB Output is correct
32 Correct 52 ms 1940 KB Output is correct
33 Correct 58 ms 2316 KB Output is correct
34 Correct 63 ms 2396 KB Output is correct
35 Correct 56 ms 2212 KB Output is correct
36 Correct 54 ms 2060 KB Output is correct
37 Correct 54 ms 2260 KB Output is correct
38 Correct 56 ms 2184 KB Output is correct
39 Correct 72 ms 2252 KB Output is correct
40 Correct 57 ms 2020 KB Output is correct
41 Correct 52 ms 1872 KB Output is correct
42 Correct 46 ms 1644 KB Output is correct
43 Correct 58 ms 2380 KB Output is correct
44 Correct 56 ms 2160 KB Output is correct
45 Correct 50 ms 1828 KB Output is correct
46 Correct 73 ms 2616 KB Output is correct
47 Correct 76 ms 2708 KB Output is correct
48 Correct 66 ms 4968 KB Output is correct
49 Correct 67 ms 4972 KB Output is correct
50 Correct 69 ms 4976 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Incorrect 1 ms 212 KB Output isn't correct
72 Halted 0 ms 0 KB -