답안 #593605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593605 2022-07-11T12:29:17 Z nguyentu Nautilus (BOI19_nautilus) C++14
66 / 100
92 ms 262144 KB
#include <bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define ii pair<int , int>  
#define iv pair<ii , ii>
#define iii pair<int , ii>
#define fi first
#define se second
#define int long long
const int inf = 1e18 + 7;
const int MAX_N = 5e2 + 7;
const int MOD = 1e9 + 7;

char a[MAX_N][MAX_N];
int f[MAX_N][MAX_N][950];
char s[5007];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int n , m , l; cin >> n >> m >> l;
    for (int i = 1 ; i <= n ; i++) {
        for (int j = 1 ; j <= m ; j++) {
            cin >> a[i][j];
        }
    }   
    for (int i = 1 ; i <= n ; i++) {
        for (int j = 1 ; j <= m ; j++) {
            if (a[i][j] != '#') {
                f[i][j][0] = 1;
            } 
        }
    }
    for (int i = 1 ; i <= l ; i++) {
        cin >> s[i];
    }
    for (int h = 1 ; h <= l ; h++) {
        for (int i = 1 ; i <= n ;i ++) {
            for (int j = 1 ; j <= m ; j++) {
                if (a[i][j] == '#') continue;;
                if (s[h] == 'W' && j < m) {
                    f[i][j][h] = f[i][j + 1][h - 1];
                }
                if (s[h] == 'N' && i < n) {
                    f[i][j][h] = f[i + 1][j][h - 1]; 
                }
                if (s[h] == 'E' && 1 < j) {
                    f[i][j][h] = f[i][j - 1][h - 1];
                }
                if (s[h] == 'S' && 1 < i) {
                    f[i][j][h] = f[i - 1][j][h - 1];
                }
                if (s[h] == '?') {
                    if (j < m && f[i][j + 1][h - 1]) f[i][j][h] = f[i][j + 1][h - 1];
                    if (i < n && f[i + 1][j][h - 1]) f[i][j][h] = f[i + 1][j][h - 1];
                    if (1 < j && f[i][j - 1][h - 1]) f[i][j][h] = f[i][j - 1][h - 1];
                    if (1 < i && f[i - 1][j][h - 1]) f[i][j][h] = f[i - 1][j][h - 1];
                }
            }
        }
    }
    int ans = 0;
    int cnt = 0;
    for (int i = 1 ; i <= n ;i ++) {
        for (int j = 1 ; j <= m ; j++) {
        if (f[i][j][l]) {
                ans++;
            }
            //cout << f[i][j][l] << " ";
        }
        //cout << '\n';
    }
    cout << ans;
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:67:9: warning: unused variable 'cnt' [-Wunused-variable]
   67 |     int cnt = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 48716 KB Output is correct
2 Correct 25 ms 38956 KB Output is correct
3 Correct 22 ms 29648 KB Output is correct
4 Correct 23 ms 20512 KB Output is correct
5 Correct 14 ms 10632 KB Output is correct
6 Correct 8 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 48716 KB Output is correct
2 Correct 25 ms 38956 KB Output is correct
3 Correct 22 ms 29648 KB Output is correct
4 Correct 23 ms 20512 KB Output is correct
5 Correct 14 ms 10632 KB Output is correct
6 Correct 8 ms 1176 KB Output is correct
7 Correct 36 ms 48724 KB Output is correct
8 Correct 25 ms 29388 KB Output is correct
9 Correct 20 ms 20504 KB Output is correct
10 Correct 14 ms 10708 KB Output is correct
11 Correct 6 ms 1108 KB Output is correct
12 Correct 29 ms 48724 KB Output is correct
13 Correct 30 ms 39380 KB Output is correct
14 Correct 29 ms 29460 KB Output is correct
15 Correct 16 ms 10580 KB Output is correct
16 Correct 8 ms 1128 KB Output is correct
17 Correct 37 ms 48724 KB Output is correct
18 Correct 31 ms 39444 KB Output is correct
19 Correct 22 ms 19940 KB Output is correct
20 Correct 14 ms 10068 KB Output is correct
21 Correct 7 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 48716 KB Output is correct
2 Correct 25 ms 38956 KB Output is correct
3 Correct 22 ms 29648 KB Output is correct
4 Correct 23 ms 20512 KB Output is correct
5 Correct 14 ms 10632 KB Output is correct
6 Correct 8 ms 1176 KB Output is correct
7 Correct 36 ms 48724 KB Output is correct
8 Correct 25 ms 29388 KB Output is correct
9 Correct 20 ms 20504 KB Output is correct
10 Correct 14 ms 10708 KB Output is correct
11 Correct 6 ms 1108 KB Output is correct
12 Correct 29 ms 48724 KB Output is correct
13 Correct 30 ms 39380 KB Output is correct
14 Correct 29 ms 29460 KB Output is correct
15 Correct 16 ms 10580 KB Output is correct
16 Correct 8 ms 1128 KB Output is correct
17 Correct 37 ms 48724 KB Output is correct
18 Correct 31 ms 39444 KB Output is correct
19 Correct 22 ms 19940 KB Output is correct
20 Correct 14 ms 10068 KB Output is correct
21 Correct 7 ms 1148 KB Output is correct
22 Runtime error 92 ms 262144 KB Execution killed with signal 9
23 Halted 0 ms 0 KB -