# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
128564 |
2019-07-11T06:38:41 Z |
구재현(#3166) |
None (JOI16_ho_t4) |
C++14 |
|
23 ms |
2792 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
using lint = long long;
using pi = pair<lint, lint>;
int n, k;
char str[MAXN];
int main(){
scanf("%d %d",&n,&k);
scanf("%s", str);
vector<pi> v = {pi(0, 0)};
lint px = 0, py = 0;
for(int j=0; j<n; j++){
if(str[j] == 'E') px++;
if(str[j] == 'W') px--;
if(str[j] == 'N') py++;
if(str[j] == 'S') py--;
v.emplace_back(px, py);
}
if(v.back().first < 0){
for(auto &i : v) i.first *= -1;
}
if(v.back().second < 0){
for(auto &i : v) i.second *= -1;
}
if(v.back().second == 0){
for(auto &i : v) swap(i.first, i.second);
}
if(v.back() == pi(0, 0)) k = 1;
if(k != 1) return 1;
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
lint ret = 0;
for(auto &i : v){
if(binary_search(v.begin(), v.end(), pi(i.first + 1, i.second)) &&
binary_search(v.begin(), v.end(), pi(i.first, 1 + i.second)) &&
binary_search(v.begin(), v.end(), pi(i.first + 1, 1 + i.second))){
ret++;
}
}
cout << ret << endl;
return 0;
}
Compilation message
2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&k);
~~~~~^~~~~~~~~~~~~~~
2016_ho_t4.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", str);
~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 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 |
632 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 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 |
632 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
28 |
Correct |
4 ms |
760 KB |
Output is correct |
29 |
Correct |
10 ms |
1648 KB |
Output is correct |
30 |
Correct |
14 ms |
2668 KB |
Output is correct |
31 |
Correct |
21 ms |
2668 KB |
Output is correct |
32 |
Correct |
18 ms |
2664 KB |
Output is correct |
33 |
Correct |
19 ms |
2668 KB |
Output is correct |
34 |
Correct |
18 ms |
2664 KB |
Output is correct |
35 |
Correct |
18 ms |
2668 KB |
Output is correct |
36 |
Correct |
19 ms |
2664 KB |
Output is correct |
37 |
Correct |
18 ms |
2664 KB |
Output is correct |
38 |
Correct |
18 ms |
2664 KB |
Output is correct |
39 |
Correct |
19 ms |
2668 KB |
Output is correct |
40 |
Correct |
18 ms |
2664 KB |
Output is correct |
41 |
Correct |
18 ms |
2792 KB |
Output is correct |
42 |
Correct |
17 ms |
2664 KB |
Output is correct |
43 |
Correct |
19 ms |
2664 KB |
Output is correct |
44 |
Correct |
18 ms |
2668 KB |
Output is correct |
45 |
Correct |
18 ms |
2664 KB |
Output is correct |
46 |
Correct |
21 ms |
2664 KB |
Output is correct |
47 |
Correct |
23 ms |
2668 KB |
Output is correct |
48 |
Correct |
17 ms |
2668 KB |
Output is correct |
49 |
Correct |
22 ms |
2664 KB |
Output is correct |
50 |
Correct |
11 ms |
2668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 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 |
632 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
380 KB |
Output is correct |
24 |
Correct |
2 ms |
256 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Runtime error |
2 ms |
256 KB |
Execution failed because the return code was nonzero |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 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 |
632 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
28 |
Correct |
4 ms |
760 KB |
Output is correct |
29 |
Correct |
10 ms |
1648 KB |
Output is correct |
30 |
Correct |
14 ms |
2668 KB |
Output is correct |
31 |
Correct |
21 ms |
2668 KB |
Output is correct |
32 |
Correct |
18 ms |
2664 KB |
Output is correct |
33 |
Correct |
19 ms |
2668 KB |
Output is correct |
34 |
Correct |
18 ms |
2664 KB |
Output is correct |
35 |
Correct |
18 ms |
2668 KB |
Output is correct |
36 |
Correct |
19 ms |
2664 KB |
Output is correct |
37 |
Correct |
18 ms |
2664 KB |
Output is correct |
38 |
Correct |
18 ms |
2664 KB |
Output is correct |
39 |
Correct |
19 ms |
2668 KB |
Output is correct |
40 |
Correct |
18 ms |
2664 KB |
Output is correct |
41 |
Correct |
18 ms |
2792 KB |
Output is correct |
42 |
Correct |
17 ms |
2664 KB |
Output is correct |
43 |
Correct |
19 ms |
2664 KB |
Output is correct |
44 |
Correct |
18 ms |
2668 KB |
Output is correct |
45 |
Correct |
18 ms |
2664 KB |
Output is correct |
46 |
Correct |
21 ms |
2664 KB |
Output is correct |
47 |
Correct |
23 ms |
2668 KB |
Output is correct |
48 |
Correct |
17 ms |
2668 KB |
Output is correct |
49 |
Correct |
22 ms |
2664 KB |
Output is correct |
50 |
Correct |
11 ms |
2668 KB |
Output is correct |
51 |
Runtime error |
2 ms |
256 KB |
Execution failed because the return code was nonzero |
52 |
Halted |
0 ms |
0 KB |
- |