Submission #881505

# Submission time Handle Problem Language Result Execution time Memory
881505 2023-12-01T10:31:36 Z 12345678 Nautilus (BOI19_nautilus) C++17
66 / 100
7 ms 1624 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=105;
int r, c, m, dx[4]={1, 0, 0, -1}, dy[4]={0, 1, -1, 0}, en[100], cnt;
char mp[nx][nx];
bool dp[nx][nx][nx];
string s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    en['N']=1; en['W']=0; en['E']=3; en['S']=2;
    cin>>r>>c>>m;
    for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) cin>>mp[i][j], dp[0][i][j]=(mp[i][j]=='.');
    cin>>s;
    for (int i=1; i<=m; i++)
    {
        for (int j=1; j<=r; j++)
        {
            for (int k=1; k<=c; k++)
            {
                if (mp[j][k]!='#')
                {
                    if (s[i-1]=='?') for (int l=0; l<4; l++) dp[i][j][k]|=dp[i-1][j+dy[l]][k+dx[l]];
                    else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
                }
                if (i==m&&dp[i][j][k]) cnt++;
                //cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
            }
        }
    }
    cout<<cnt;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:27:60: warning: array subscript has type 'char' [-Wchar-subscripts]
   27 |                     else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
      |                                                            ^
nautilus.cpp:27:78: warning: array subscript has type 'char' [-Wchar-subscripts]
   27 |                     else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
      |                                                                              ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1424 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1368 KB Output is correct
5 Correct 2 ms 1372 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1424 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1368 KB Output is correct
5 Correct 2 ms 1372 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 5 ms 1500 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 6 ms 1624 KB Output is correct
10 Correct 3 ms 1372 KB Output is correct
11 Correct 1 ms 868 KB Output is correct
12 Correct 6 ms 1372 KB Output is correct
13 Correct 7 ms 1372 KB Output is correct
14 Correct 7 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 7 ms 1372 KB Output is correct
18 Correct 7 ms 1500 KB Output is correct
19 Correct 6 ms 1372 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1372 KB Output is correct
2 Correct 3 ms 1424 KB Output is correct
3 Correct 4 ms 1372 KB Output is correct
4 Correct 4 ms 1368 KB Output is correct
5 Correct 2 ms 1372 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 5 ms 1500 KB Output is correct
8 Correct 6 ms 1372 KB Output is correct
9 Correct 6 ms 1624 KB Output is correct
10 Correct 3 ms 1372 KB Output is correct
11 Correct 1 ms 868 KB Output is correct
12 Correct 6 ms 1372 KB Output is correct
13 Correct 7 ms 1372 KB Output is correct
14 Correct 7 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 7 ms 1372 KB Output is correct
18 Correct 7 ms 1500 KB Output is correct
19 Correct 6 ms 1372 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Runtime error 1 ms 860 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -