| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1367054 | nataliaa | Nautilus (BOI19_nautilus) | C++20 | 1 ms | 344 KiB |
#include<bits/stdc++.h>
using namespace std;
int n, m, k;
string s;
char a[105][105];
int check(int i, int j, int idx){
if(idx==k) return 1;
if(s[i]=='N'){
if(i==0) return 0;
if(a[i-1][j]=='#') return 0;
return (i-1, j, idx+1);
}
if(s[i]=='E'){
if(j==m-1) return 0;
if(a[i][j+1]=='#') return 0;
return (i, j+1, idx+1);
}
if(s[i]=='S'){
if(i==n-1) return 0;
if(a[i+1][j]=='#') return 0;
return (i+1, j, idx+1);
}
if(s[i]=='W'){
if(j==0) return 0;
if(a[i][j-1]=='#') return 0;
return (i, j-1, idx+1);
}
}
int main(){
cin >> n >> m >> k;;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> a[i][j];
}
}
cin >> s;
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
// if(check(i,j,0)==1) cout << i <<' '<< j <<endl;
if(a[i][j]=='.')ans+=check(i, j, 0);
}
}
cout << ans;
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
