Submission #533605

#TimeUsernameProblemLanguageResultExecution timeMemory
533605ddy888Nautilus (BOI19_nautilus)C++17
66 / 100
33 ms40644 KiB
#undef _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int long long #define pb push_back #define fi first #define si second #define ar array typedef pair<int,int> pi; typedef tuple<int,int,int> ti; void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) // O(RCM) int R, C, M, dp[510][510][510], ans; char A[510][510], ops[510]; inline void chmax(int &x, int y) { x = max(x, y); } int check(int i, int j, int idx) { if (i > R || j > C) return 0; if (A[i][j] == '#') return 0; if (idx == 0) return 1; return dp[i][j][idx]; } signed main() { fast; cin >> R >> C >> M; assert(M <= 100); for (int i = 1; i <= R; ++i) { for (int j = 1; j <= C; ++j) cin >> A[i][j]; } for (int i = 1; i <= M; ++i) cin >> ops[i]; for (int k = 1; k <= M; ++k) { for (int i = 1; i <= R; ++i) { for (int j = 1; j <= C; ++j) { if (A[i][j] == '#') continue; if (ops[k] == 'N' || ops[k] == '?') chmax(dp[i][j][k], check(i + 1, j, k - 1)); if (ops[k] == 'E' || ops[k] == '?') chmax(dp[i][j][k], check(i, j - 1, k - 1)); if (ops[k] == 'W' || ops[k] == '?') chmax(dp[i][j][k], check(i, j + 1, k - 1)); if (ops[k] == 'S' || ops[k] == '?') chmax(dp[i][j][k], check(i - 1, j, k - 1)); // debug(dp[i][j][k], i, j, k); } } } for (int i = 1; i <= R; ++i) { for (int j = 1; j <= C; ++j) { // if (A[i][j] == '#') cout << '#'; // else cout << dp[i][j][M]; ans += dp[i][j][M]; } // cout << '\n'; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...