답안 #594081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594081 2022-07-12T05:05:26 Z 반딧불(#8432) 영역 (JOI16_ho_t4) C++17
28 / 100
1000 ms 18080 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int LIM = 30;

const int xx[]={0, 1, 0, -1}, yy[]={1, 0, -1, 0};

int n, k;
int arr[100002];
set<pair<int, int> > st;
ll ans[52];

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++){
        char c;
        scanf(" %c", &c);
        if(c == 'N') arr[i] = 0;
        else if(c == 'E') arr[i] = 1;
        else if(c == 'S') arr[i] = 2;
        else arr[i] = 3;
    }
    st.insert(make_pair(0, 0));
    int x = 0, y = 0;
    for(int turn=1; turn<=LIM; turn++){
        for(int i=1; i<=n; i++){
            x += xx[arr[i]], y += yy[arr[i]];
            st.insert(make_pair(x, y));
        }
        for(auto p: st){
            if(st.find(make_pair(p.first, p.second+1)) == st.end() || st.find(make_pair(p.first+1, p.second)) == st.end() ||
               st.find(make_pair(p.first+1, p.second+1)) == st.end()) continue;
            ans[turn]++;
        }
//        printf("%d: %lld\n", turn, ans[turn]);
    }
    if(k<=LIM) printf("%lld", ans[k]);
    else printf("%lld", ans[LIM] + (ans[LIM] - ans[LIM-1]) * (k - LIM));
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
2016_ho_t4.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 8 ms 340 KB Output is correct
27 Correct 96 ms 1584 KB Output is correct
28 Correct 47 ms 468 KB Output is correct
29 Execution timed out 1083 ms 18080 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 324 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Correct 2 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 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 2 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 328 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 2 ms 212 KB Output is correct
48 Correct 2 ms 340 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 8 ms 340 KB Output is correct
27 Correct 96 ms 1584 KB Output is correct
28 Correct 47 ms 468 KB Output is correct
29 Execution timed out 1083 ms 18080 KB Time limit exceeded
30 Halted 0 ms 0 KB -