Submission #117169

# Submission time Handle Problem Language Result Execution time Memory
117169 2019-06-15T06:18:21 Z onjo0127 None (JOI16_ho_t4) C++11
15 / 100
158 ms 11384 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, K, x, y));
        if(K <= 50) printf("%d", t);
        else printf("%lld", 1LL * (cnt(rep(st, K+1, x, y)) - t) * (K - 50) + 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 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 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 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 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 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 14 ms 1664 KB Output is correct
30 Correct 16 ms 1792 KB Output is correct
31 Correct 114 ms 8312 KB Output is correct
32 Correct 24 ms 2296 KB Output is correct
33 Correct 24 ms 2688 KB Output is correct
34 Correct 25 ms 2936 KB Output is correct
35 Correct 24 ms 2688 KB Output is correct
36 Correct 23 ms 2432 KB Output is correct
37 Correct 24 ms 2616 KB Output is correct
38 Correct 23 ms 2560 KB Output is correct
39 Correct 26 ms 2688 KB Output is correct
40 Correct 23 ms 2304 KB Output is correct
41 Correct 21 ms 2304 KB Output is correct
42 Correct 19 ms 2048 KB Output is correct
43 Correct 24 ms 2944 KB Output is correct
44 Correct 26 ms 2548 KB Output is correct
45 Correct 21 ms 2176 KB Output is correct
46 Correct 33 ms 5112 KB Output is correct
47 Correct 37 ms 5060 KB Output is correct
48 Correct 53 ms 9780 KB Output is correct
49 Correct 45 ms 9848 KB Output is correct
50 Correct 47 ms 9984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 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 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Incorrect 158 ms 11384 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 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 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 5 ms 640 KB Output is correct
29 Correct 14 ms 1664 KB Output is correct
30 Correct 16 ms 1792 KB Output is correct
31 Correct 114 ms 8312 KB Output is correct
32 Correct 24 ms 2296 KB Output is correct
33 Correct 24 ms 2688 KB Output is correct
34 Correct 25 ms 2936 KB Output is correct
35 Correct 24 ms 2688 KB Output is correct
36 Correct 23 ms 2432 KB Output is correct
37 Correct 24 ms 2616 KB Output is correct
38 Correct 23 ms 2560 KB Output is correct
39 Correct 26 ms 2688 KB Output is correct
40 Correct 23 ms 2304 KB Output is correct
41 Correct 21 ms 2304 KB Output is correct
42 Correct 19 ms 2048 KB Output is correct
43 Correct 24 ms 2944 KB Output is correct
44 Correct 26 ms 2548 KB Output is correct
45 Correct 21 ms 2176 KB Output is correct
46 Correct 33 ms 5112 KB Output is correct
47 Correct 37 ms 5060 KB Output is correct
48 Correct 53 ms 9780 KB Output is correct
49 Correct 45 ms 9848 KB Output is correct
50 Correct 47 ms 9984 KB Output is correct
51 Incorrect 158 ms 11384 KB Output isn't correct
52 Halted 0 ms 0 KB -