# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
117170 |
2019-06-15T06:19:38 Z |
onjo0127 |
None (JOI16_ho_t4) |
C++11 |
|
89 ms |
11256 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 <= 500) printf("%d", t);
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 |
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 |
2 ms |
384 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 |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 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 |
2 ms |
384 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 |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
640 KB |
Output is correct |
29 |
Correct |
14 ms |
1664 KB |
Output is correct |
30 |
Correct |
17 ms |
1792 KB |
Output is correct |
31 |
Correct |
43 ms |
8312 KB |
Output is correct |
32 |
Correct |
22 ms |
2304 KB |
Output is correct |
33 |
Correct |
24 ms |
2808 KB |
Output is correct |
34 |
Correct |
24 ms |
2944 KB |
Output is correct |
35 |
Correct |
25 ms |
2680 KB |
Output is correct |
36 |
Correct |
23 ms |
2432 KB |
Output is correct |
37 |
Correct |
24 ms |
2816 KB |
Output is correct |
38 |
Correct |
24 ms |
2552 KB |
Output is correct |
39 |
Correct |
24 ms |
2688 KB |
Output is correct |
40 |
Correct |
22 ms |
2432 KB |
Output is correct |
41 |
Correct |
21 ms |
2304 KB |
Output is correct |
42 |
Correct |
21 ms |
1916 KB |
Output is correct |
43 |
Correct |
27 ms |
2944 KB |
Output is correct |
44 |
Correct |
24 ms |
2552 KB |
Output is correct |
45 |
Correct |
22 ms |
2176 KB |
Output is correct |
46 |
Correct |
36 ms |
5112 KB |
Output is correct |
47 |
Correct |
37 ms |
5120 KB |
Output is correct |
48 |
Correct |
55 ms |
9848 KB |
Output is correct |
49 |
Correct |
44 ms |
9848 KB |
Output is correct |
50 |
Correct |
46 ms |
9856 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 |
2 ms |
384 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 |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Incorrect |
89 ms |
11256 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 |
2 ms |
384 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 |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 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 |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
640 KB |
Output is correct |
29 |
Correct |
14 ms |
1664 KB |
Output is correct |
30 |
Correct |
17 ms |
1792 KB |
Output is correct |
31 |
Correct |
43 ms |
8312 KB |
Output is correct |
32 |
Correct |
22 ms |
2304 KB |
Output is correct |
33 |
Correct |
24 ms |
2808 KB |
Output is correct |
34 |
Correct |
24 ms |
2944 KB |
Output is correct |
35 |
Correct |
25 ms |
2680 KB |
Output is correct |
36 |
Correct |
23 ms |
2432 KB |
Output is correct |
37 |
Correct |
24 ms |
2816 KB |
Output is correct |
38 |
Correct |
24 ms |
2552 KB |
Output is correct |
39 |
Correct |
24 ms |
2688 KB |
Output is correct |
40 |
Correct |
22 ms |
2432 KB |
Output is correct |
41 |
Correct |
21 ms |
2304 KB |
Output is correct |
42 |
Correct |
21 ms |
1916 KB |
Output is correct |
43 |
Correct |
27 ms |
2944 KB |
Output is correct |
44 |
Correct |
24 ms |
2552 KB |
Output is correct |
45 |
Correct |
22 ms |
2176 KB |
Output is correct |
46 |
Correct |
36 ms |
5112 KB |
Output is correct |
47 |
Correct |
37 ms |
5120 KB |
Output is correct |
48 |
Correct |
55 ms |
9848 KB |
Output is correct |
49 |
Correct |
44 ms |
9848 KB |
Output is correct |
50 |
Correct |
46 ms |
9856 KB |
Output is correct |
51 |
Incorrect |
89 ms |
11256 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |