Submission #1126698

#TimeUsernameProblemLanguageResultExecution timeMemory
1126698FucKanhNautilus (BOI19_nautilus)C++20
66 / 100
11 ms4164 KiB
#include<bits/stdc++.h> #define ll long long #define int ll #define pii pair<int,int> using namespace std; const int maxn = 505; int n,m,q; int a[maxn][maxn], fix[maxn][maxn]; string s; namespace SUB1 { int b[maxn][maxn]; void solve() { for (int i = 1; i <= q; i++) { // for (int x = 1; x <= n; x++) { // for (int y = 1; y <= m; y++) { // cerr << a[x][y] << " "; // } cerr << endl; // } cerr << endl; if (s[i-1] == 'W') { for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { b[x][y] = a[x][y+1]; } } } else if (s[i-1] == 'E') { for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { b[x][y] = a[x][y-1]; } } } else if (s[i-1] == 'S') { for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { b[x][y] = a[x-1][y]; } } } else if (s[i-1] == 'N') { for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { b[x][y] = a[x+1][y]; } } } else { for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { b[x][y] = a[x-1][y] || a[x+1][y] || a[x][y-1] || a[x][y+1]; } } } for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { a[x][y] = b[x][y] && fix[x][y]; } } // for (int x = 1; x <= n; x++) { // for (int y = 1; y <= m; y++) { // cerr << a[x][y] << " "; // } cerr << endl; // } cerr << endl; } int ans = 0; for (int x = 1; x <= n; x++) { for (int y = 1; y <= m; y++) { ans += a[x][y]; } } cout << ans; } } void solve() { cin >> n >> m >> q; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char c; cin >> c; if (c == '.') fix[i][j] = a[i][j] = 1; } } cin >> s; if (n <= 100 && m <= 100 && q <= 100) SUB1::solve(); } signed main() { cin.tie(0) -> sync_with_stdio(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...