제출 #868606

#제출 시각아이디문제언어결과실행 시간메모리
868606NeroZeinNautilus (BOI19_nautilus)C++17
29 / 100
1047 ms32628 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...