| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1367112 | nataliaa | Nautilus (BOI19_nautilus) | C++20 | 2 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(a[i][j]=='#') return 0;
if(idx==k) return 1;
if(s[idx]=='N'){
if(i==0) return 0;
return check(i-1, j, idx+1);
}
if(s[idx]=='E'){
if(j==m-1) return 0;
return check(i, j+1, idx+1);
}
if(s[idx]=='S'){
if(i==n-1) return 0;
return check(i+1, j, idx+1);
}
if(s[idx]=='W'){
if(j==0) return 0;
return check(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;
// cout << check(1, 6, 0)<<endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
// if(check(i,j,0)==1) cout << i <<' '<< j <<endl;
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... | ||||
