Submission #1021860

# Submission time Handle Problem Language Result Execution time Memory
1021860 2024-07-13T06:21:14 Z basa Nautilus (BOI19_nautilus) C++14
66 / 100
379 ms 262144 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
string m;
int r, c, k;
string s[505];
bool vis[505][505][5005];
 
int dfs(int i, int j, int p){
  if(i >= r || i < 0) return 0;
  if(j >= c || j < 0) return 0;
  if(s[i][j] == '#') return 0;
  if(vis[i][j][p]) return 0;
  vis[i][j][p] = 1;
  if(p == m.size()) return 1;
 
 
  int ret = 0;
 
  if(m[p] == 'N') ret = dfs(i - 1, j, p + 1);
  if(m[p] == 'S') ret = dfs(i + 1, j, p + 1);
  if(m[p] == 'E') ret = dfs(i, j + 1, p + 1);
  if(m[p] == 'W') ret = dfs(i, j - 1, p + 1);
 
  if(m[p] == '?'){
    ret += dfs(i + 1, j, p + 1);
    ret += dfs(i - 1, j, p + 1);
    ret += dfs(i, j + 1, p + 1);
    ret += dfs(i, j - 1, p + 1);
  }
 
  return ret;
}
 
signed main()
{
  cin.tie(0) -> sync_with_stdio(0);
  cin >> r >> c >> k;
 
  for(int i = 0; i < r; i++) cin >> s[i];
 
  cin >> m;
 
  int ans = 0;
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      if(s[i][j] == '#') continue;
      ans += dfs(i, j, 0);
    }
  }
 
  cout << ans;
}

Compilation message

nautilus.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
nautilus.cpp:18:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(p == m.size()) return 1;
      |      ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 36 ms 41808 KB Output is correct
2 Correct 16 ms 32860 KB Output is correct
3 Correct 11 ms 25068 KB Output is correct
4 Correct 9 ms 17244 KB Output is correct
5 Correct 5 ms 9108 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 41808 KB Output is correct
2 Correct 16 ms 32860 KB Output is correct
3 Correct 11 ms 25068 KB Output is correct
4 Correct 9 ms 17244 KB Output is correct
5 Correct 5 ms 9108 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 37 ms 41760 KB Output is correct
8 Correct 16 ms 25180 KB Output is correct
9 Correct 9 ms 17240 KB Output is correct
10 Correct 5 ms 9160 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 42 ms 41772 KB Output is correct
13 Correct 43 ms 33872 KB Output is correct
14 Correct 25 ms 25436 KB Output is correct
15 Correct 6 ms 9048 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 47 ms 41876 KB Output is correct
18 Correct 40 ms 33876 KB Output is correct
19 Correct 15 ms 17500 KB Output is correct
20 Correct 7 ms 9304 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 41808 KB Output is correct
2 Correct 16 ms 32860 KB Output is correct
3 Correct 11 ms 25068 KB Output is correct
4 Correct 9 ms 17244 KB Output is correct
5 Correct 5 ms 9108 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 37 ms 41760 KB Output is correct
8 Correct 16 ms 25180 KB Output is correct
9 Correct 9 ms 17240 KB Output is correct
10 Correct 5 ms 9160 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 42 ms 41772 KB Output is correct
13 Correct 43 ms 33872 KB Output is correct
14 Correct 25 ms 25436 KB Output is correct
15 Correct 6 ms 9048 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 47 ms 41876 KB Output is correct
18 Correct 40 ms 33876 KB Output is correct
19 Correct 15 ms 17500 KB Output is correct
20 Correct 7 ms 9304 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Runtime error 379 ms 262144 KB Execution killed with signal 9
23 Halted 0 ms 0 KB -