Submission #489137

# Submission time Handle Problem Language Result Execution time Memory
489137 2021-11-21T09:28:09 Z ak2006 Nautilus (BOI19_nautilus) C++14
66 / 100
118 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize("Ofast")
int main()
{
    fast;

    int r,c,m;
    cin>>r>>c>>m;
    char g[r + 1][c + 1];
    bool dp[r + 2][c + 2][m + 1];
    memset(dp,false,sizeof(dp));
    for (int i = 1;i<=r;i++)
        for (int j = 1;j<=c;j++)
            cin>>g[i][j],dp[i][j][0] = (g[i][j] != '#');
    string s;
    cin>>s;
    int ans = 0;
    for (int t = 1;t<=m;t++){
        for (int i = 1;i<=r;i++){
            for (int j = 1;j<=c;j++){
                if (g[i][j] == '#')continue;
                if (s[t - 1] == 'E')
                    dp[i][j][t] = dp[i][j - 1][t - 1];
                else if (s[t - 1] == 'W')
                    dp[i][j][t] = dp[i][j + 1][t - 1];
                else if (s[t - 1] == 'N')
                    dp[i][j][t] = dp[i + 1][j][t - 1];
                else if (s[t - 1] == 'S')
                    dp[i][j][t] = dp[i - 1][j][t - 1];
                else dp[i][j][t] = dp[i - 1][j][t - 1] or 
                    dp[i + 1][j][t - 1] or
                dp[i][j + 1][t - 1] or dp[i][j - 1][t - 1];
                if (t == m)
                    ans += dp[i][j][t];
            }
        }
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1340 KB Output is correct
2 Correct 4 ms 1228 KB Output is correct
3 Correct 6 ms 1228 KB Output is correct
4 Correct 6 ms 1356 KB Output is correct
5 Correct 4 ms 1356 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1340 KB Output is correct
2 Correct 4 ms 1228 KB Output is correct
3 Correct 6 ms 1228 KB Output is correct
4 Correct 6 ms 1356 KB Output is correct
5 Correct 4 ms 1356 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 4 ms 1356 KB Output is correct
8 Correct 7 ms 1228 KB Output is correct
9 Correct 6 ms 1356 KB Output is correct
10 Correct 4 ms 1240 KB Output is correct
11 Correct 2 ms 1228 KB Output is correct
12 Correct 4 ms 1228 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 9 ms 1228 KB Output is correct
15 Correct 5 ms 1356 KB Output is correct
16 Correct 2 ms 1356 KB Output is correct
17 Correct 6 ms 1340 KB Output is correct
18 Correct 7 ms 1228 KB Output is correct
19 Correct 7 ms 1388 KB Output is correct
20 Correct 5 ms 1316 KB Output is correct
21 Correct 2 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1340 KB Output is correct
2 Correct 4 ms 1228 KB Output is correct
3 Correct 6 ms 1228 KB Output is correct
4 Correct 6 ms 1356 KB Output is correct
5 Correct 4 ms 1356 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 4 ms 1356 KB Output is correct
8 Correct 7 ms 1228 KB Output is correct
9 Correct 6 ms 1356 KB Output is correct
10 Correct 4 ms 1240 KB Output is correct
11 Correct 2 ms 1228 KB Output is correct
12 Correct 4 ms 1228 KB Output is correct
13 Correct 7 ms 1356 KB Output is correct
14 Correct 9 ms 1228 KB Output is correct
15 Correct 5 ms 1356 KB Output is correct
16 Correct 2 ms 1356 KB Output is correct
17 Correct 6 ms 1340 KB Output is correct
18 Correct 7 ms 1228 KB Output is correct
19 Correct 7 ms 1388 KB Output is correct
20 Correct 5 ms 1316 KB Output is correct
21 Correct 2 ms 1356 KB Output is correct
22 Runtime error 118 ms 262148 KB Execution killed with signal 9
23 Halted 0 ms 0 KB -