# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315733 | 2020-10-23T20:09:49 Z | dCoding | Nautilus (BOI19_nautilus) | C++17 | 622 ms | 256508 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second const int MAXN=505; bool dp[MAXN][MAXN][MAXN]; int n,m,k; char str[5005]; char grid[MAXN][MAXN]; int main() { scanf("%d%d%d",&n,&m,&k); for(int i=0;i<n;i++) scanf("%s",grid[i]); scanf("%s",str+1); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { dp[0][i][j]=grid[i][j]=='.'; } } for(int c=1;c<=k;c++) { for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(grid[i][j]=='#') continue; if(str[c]=='N') { if(dp[c-1][i][j]&&i-1>=0&&grid[i-1][j]=='.') { dp[c][i-1][j]=true; } } else if(str[c]=='S') { if(dp[c-1][i][j]&&i+1<n&&grid[i+1][j]=='.') { dp[c][i+1][j]=true; } } else if(str[c]=='E') { if(dp[c-1][i][j]&&j+1<m&&grid[i][j+1]=='.') { dp[c][i][j+1]=true; } } else if(str[c]=='W') { if(dp[c-1][i][j]&&j-1>=0&&grid[i][j-1]=='.') { dp[c][i][j-1]=true; } } else { if(dp[c-1][i][j]&&i-1>=0&&grid[i-1][j]=='.') { dp[c][i-1][j]=true; } if(dp[c-1][i][j]&&i+1<n&&grid[i+1][j]=='.') { dp[c][i+1][j]=true; } if(dp[c-1][i][j]&&j+1<m&&grid[i][j+1]=='.') { dp[c][i][j+1]=true; } if(dp[c-1][i][j]&&j-1>=0&&grid[i][j-1]=='.') { dp[c][i][j-1]=true; } } } } } int ans=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { ans+=dp[k][i][j]; } } printf("%d",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5376 KB | Output is correct |
2 | Correct | 7 ms | 4864 KB | Output is correct |
3 | Correct | 7 ms | 2560 KB | Output is correct |
4 | Correct | 7 ms | 1408 KB | Output is correct |
5 | Correct | 5 ms | 1152 KB | Output is correct |
6 | Correct | 2 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5376 KB | Output is correct |
2 | Correct | 7 ms | 4864 KB | Output is correct |
3 | Correct | 7 ms | 2560 KB | Output is correct |
4 | Correct | 7 ms | 1408 KB | Output is correct |
5 | Correct | 5 ms | 1152 KB | Output is correct |
6 | Correct | 2 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 5760 KB | Output is correct |
8 | Correct | 12 ms | 5760 KB | Output is correct |
9 | Correct | 9 ms | 4480 KB | Output is correct |
10 | Correct | 5 ms | 2176 KB | Output is correct |
11 | Correct | 2 ms | 1152 KB | Output is correct |
12 | Correct | 7 ms | 5760 KB | Output is correct |
13 | Correct | 12 ms | 5780 KB | Output is correct |
14 | Correct | 14 ms | 5760 KB | Output is correct |
15 | Correct | 6 ms | 4992 KB | Output is correct |
16 | Correct | 2 ms | 1280 KB | Output is correct |
17 | Correct | 8 ms | 5760 KB | Output is correct |
18 | Correct | 13 ms | 5760 KB | Output is correct |
19 | Correct | 11 ms | 5760 KB | Output is correct |
20 | Correct | 7 ms | 5764 KB | Output is correct |
21 | Correct | 2 ms | 1280 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5376 KB | Output is correct |
2 | Correct | 7 ms | 4864 KB | Output is correct |
3 | Correct | 7 ms | 2560 KB | Output is correct |
4 | Correct | 7 ms | 1408 KB | Output is correct |
5 | Correct | 5 ms | 1152 KB | Output is correct |
6 | Correct | 2 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 5760 KB | Output is correct |
8 | Correct | 12 ms | 5760 KB | Output is correct |
9 | Correct | 9 ms | 4480 KB | Output is correct |
10 | Correct | 5 ms | 2176 KB | Output is correct |
11 | Correct | 2 ms | 1152 KB | Output is correct |
12 | Correct | 7 ms | 5760 KB | Output is correct |
13 | Correct | 12 ms | 5780 KB | Output is correct |
14 | Correct | 14 ms | 5760 KB | Output is correct |
15 | Correct | 6 ms | 4992 KB | Output is correct |
16 | Correct | 2 ms | 1280 KB | Output is correct |
17 | Correct | 8 ms | 5760 KB | Output is correct |
18 | Correct | 13 ms | 5760 KB | Output is correct |
19 | Correct | 11 ms | 5760 KB | Output is correct |
20 | Correct | 7 ms | 5764 KB | Output is correct |
21 | Correct | 2 ms | 1280 KB | Output is correct |
22 | Runtime error | 622 ms | 256508 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
23 | Halted | 0 ms | 0 KB | - |