# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315251 | 2020-10-22T06:37:32 Z | dCoding | Nautilus (BOI19_nautilus) | C++17 | 1000 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second const int MAXN=505; char grid[MAXN][MAXN]; char str[MAXN]; int n,m,k; bool ok[MAXN][MAXN]; void dfs(int x,int y,int idx) { if(x<0||y<0||x>=n||y>=m||grid[x][y]=='#') return; if(idx==k) { ok[x][y]=true; return; } if(str[idx]=='N') dfs(x-1,y,idx+1); else if(str[idx]=='S') dfs(x+1,y,idx+1); else if(str[idx]=='E') dfs(x,y+1,idx+1); else if(str[idx]=='W') dfs(x,y-1,idx+1); else { dfs(x-1,y,idx+1); dfs(x+1,y,idx+1); dfs(x,y+1,idx+1); dfs(x,y-1,idx+1); } } int main() { scanf("%d%d%d",&n,&m,&k); for(int i=0;i<n;i++) scanf("%s",grid[i]); scanf("%s",str); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { dfs(i,j,0); } } int ans=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { ans+=ok[i][j]; } } printf("%d",ans); } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Execution timed out | 1086 ms | 504 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Execution timed out | 1086 ms | 504 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |