답안 #868606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868606 2023-11-01T01:31:25 Z NeroZein Nautilus (BOI19_nautilus) C++17
29 / 100
1000 ms 32628 KB
#include "bits/stdc++.h"
#define int long long
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

const int N = 502; 

char cc[] = {'E', 'W', 'S', 'N'};
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};//E, W, S, N

char c[N][N]; 

int n, m, k;
string s;
set<pair<int, int>> se; 
void bt(int p, int i, int j) {
  if (c[i][j] == '#' || i < 0 || i >= n || j < 0 || j >= m) {
    return; 
  }
  deb(p) deb(i) deb(j) cout << '\n';
  if (p == k) {
    se.emplace(i, j);
    return; 
  }
  if (s[p] == '?') {
    for (int z = 0; z < 4; ++z) {
      int nx = i + dx[z];
      int ny = j + dy[z];
      bt(p + 1, nx, ny); 
    }
  } else {
    for (int z = 0; z < 4; ++z) {
      if (cc[z] == s[p]) {
        int nx = i + dx[z];
        int ny = j + dy[z];
        bt(p + 1, nx, ny);
      }
    }
  }
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> c[i][j]; 
    }
  }
  cin >> s; 
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (c[i][j] != '#') {
        bt(0, i, j); 
      }
    }
  }
  cout << se.size() << '\n'; 
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1876 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1876 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1047 ms 32628 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1876 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1047 ms 32628 KB Time limit exceeded
8 Halted 0 ms 0 KB -