Submission #117171

# Submission time Handle Problem Language Result Execution time Memory
117171 2019-06-15T06:20:10 Z onjo0127 None (JOI16_ho_t4) C++11
38 / 100
1000 ms 148224 KB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

set<pii> st;
char S[100009];

int cnt(set<pii> S) {
    int ret = 0;
    for(auto& it: S) {
        int x, y; tie(x, y) = it;
        if(S.find({x+1, y}) != S.end() && S.find({x, y+1}) != S.end() && S.find({x+1, y+1}) != S.end()) ++ret;
    }
    return ret;
}

set<pii> rep(set<pii>& S, int K, int dx, int dy) {
    set<pii> ret;
    for(int i=0; i<K; i++) {
        for(auto& it: S) {
            int x, y; tie(x, y) = it;
            ret.insert({x + dx*i, y + dy*i});
        }
    }
    return ret;
}

int main() {
    int N, K; scanf("%d%d",&N,&K);
    int x = 0, y = 0; st.insert({0, 0});
    for(int i=1; i<=N; i++) {
        scanf(" %c",&S[i]);
        if(S[i] == 'N') ++y;
        if(S[i] == 'S') --y;
        if(S[i] == 'E') ++x;
        if(S[i] == 'W') --x;
        st.insert({x, y});
    }
    if(K == 1) printf("%d", cnt(st));
    else {
        int t = cnt(rep(st, 500, x, y));
        if(K <= 500) printf("%d", cnt(rep(st, K, x, y)));
        else printf("%lld", 1LL * (cnt(rep(st, 501, x, y)) - t) * (K - 500) + t);
    }
    return 0;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:29:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N, K; scanf("%d%d",&N,&K);
               ~~~~~^~~~~~~~~~~~~~
2016_ho_t4.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&S[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 484 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 13 ms 1664 KB Output is correct
30 Correct 16 ms 1792 KB Output is correct
31 Correct 44 ms 8320 KB Output is correct
32 Correct 23 ms 2424 KB Output is correct
33 Correct 25 ms 2680 KB Output is correct
34 Correct 25 ms 2936 KB Output is correct
35 Correct 26 ms 2680 KB Output is correct
36 Correct 24 ms 2432 KB Output is correct
37 Correct 25 ms 2560 KB Output is correct
38 Correct 25 ms 2560 KB Output is correct
39 Correct 27 ms 2688 KB Output is correct
40 Correct 34 ms 2424 KB Output is correct
41 Correct 21 ms 2304 KB Output is correct
42 Correct 20 ms 1920 KB Output is correct
43 Correct 25 ms 3032 KB Output is correct
44 Correct 24 ms 2688 KB Output is correct
45 Correct 21 ms 2176 KB Output is correct
46 Correct 38 ms 5112 KB Output is correct
47 Correct 37 ms 5112 KB Output is correct
48 Correct 53 ms 9780 KB Output is correct
49 Correct 46 ms 9724 KB Output is correct
50 Correct 46 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 7 ms 768 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 13 ms 1024 KB Output is correct
29 Correct 7 ms 1024 KB Output is correct
30 Correct 6 ms 640 KB Output is correct
31 Correct 6 ms 640 KB Output is correct
32 Correct 11 ms 896 KB Output is correct
33 Correct 9 ms 896 KB Output is correct
34 Correct 16 ms 896 KB Output is correct
35 Correct 10 ms 1024 KB Output is correct
36 Correct 7 ms 640 KB Output is correct
37 Correct 12 ms 1152 KB Output is correct
38 Correct 8 ms 640 KB Output is correct
39 Correct 8 ms 768 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 6 ms 656 KB Output is correct
42 Correct 2 ms 256 KB Output is correct
43 Correct 10 ms 896 KB Output is correct
44 Correct 5 ms 512 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 7 ms 640 KB Output is correct
48 Correct 9 ms 896 KB Output is correct
49 Correct 6 ms 384 KB Output is correct
50 Correct 14 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 484 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 13 ms 1664 KB Output is correct
30 Correct 16 ms 1792 KB Output is correct
31 Correct 44 ms 8320 KB Output is correct
32 Correct 23 ms 2424 KB Output is correct
33 Correct 25 ms 2680 KB Output is correct
34 Correct 25 ms 2936 KB Output is correct
35 Correct 26 ms 2680 KB Output is correct
36 Correct 24 ms 2432 KB Output is correct
37 Correct 25 ms 2560 KB Output is correct
38 Correct 25 ms 2560 KB Output is correct
39 Correct 27 ms 2688 KB Output is correct
40 Correct 34 ms 2424 KB Output is correct
41 Correct 21 ms 2304 KB Output is correct
42 Correct 20 ms 1920 KB Output is correct
43 Correct 25 ms 3032 KB Output is correct
44 Correct 24 ms 2688 KB Output is correct
45 Correct 21 ms 2176 KB Output is correct
46 Correct 38 ms 5112 KB Output is correct
47 Correct 37 ms 5112 KB Output is correct
48 Correct 53 ms 9780 KB Output is correct
49 Correct 46 ms 9724 KB Output is correct
50 Correct 46 ms 9848 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 13 ms 1024 KB Output is correct
54 Correct 7 ms 1024 KB Output is correct
55 Correct 6 ms 640 KB Output is correct
56 Correct 6 ms 640 KB Output is correct
57 Correct 11 ms 896 KB Output is correct
58 Correct 9 ms 896 KB Output is correct
59 Correct 16 ms 896 KB Output is correct
60 Correct 10 ms 1024 KB Output is correct
61 Correct 7 ms 640 KB Output is correct
62 Correct 12 ms 1152 KB Output is correct
63 Correct 8 ms 640 KB Output is correct
64 Correct 8 ms 768 KB Output is correct
65 Correct 2 ms 384 KB Output is correct
66 Correct 6 ms 656 KB Output is correct
67 Correct 2 ms 256 KB Output is correct
68 Correct 10 ms 896 KB Output is correct
69 Correct 5 ms 512 KB Output is correct
70 Correct 7 ms 768 KB Output is correct
71 Correct 6 ms 512 KB Output is correct
72 Correct 7 ms 640 KB Output is correct
73 Correct 9 ms 896 KB Output is correct
74 Correct 6 ms 384 KB Output is correct
75 Correct 14 ms 1536 KB Output is correct
76 Correct 538 ms 18012 KB Output is correct
77 Correct 172 ms 512 KB Output is correct
78 Execution timed out 1085 ms 148224 KB Time limit exceeded
79 Halted 0 ms 0 KB -