Submission #496520

#TimeUsernameProblemLanguageResultExecution timeMemory
496520MukhitaliNautilus (BOI19_nautilus)C++17
100 / 100
173 ms764 KiB
//bit chass 1 #include <bits/stdc++.h> #define x first #define y second #define el "\n" #define ll long long #define pb push_back #define pll pair <ll, ll> #define pii pair <int, int> #define all(x) x.begin(), x.end() #define lcm(x,y) x * y / __gcd(x, y) #define ibase ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; const int N = 3e5 + 5, inf = 1e9 + 7, M = 2e6, MM = 2e6 + 5, K = 300; const ll MI = 2e18; const double P = 3.14; string s[505]; string a; int r, c, m; int ans; void solve() { cin >> r >> c >> m; bitset<500> b[r], bad[r], re, down[r], up[r], left[r], right[r]; for (int i = 0; i < 500; i++) re[i] = 0; for (int i = 0; i < r; i++) { cin >> s[i]; b[i] = bad[i] = re; for (int j = 0; j < c; j++) { b[i][j] = (s[i][j] == '.'); bad[i][j] = (s[i][j] == '.'); } } cin >> a; for (int k = 0; k < m; k++) { // for (int i = 0; i < c; i++) // cout << b[0][i]; // cout << el; if (a[k] == 'W') { for (int i = 0; i < r; i++) { b[i] = (b[i] >> 1); b[i] = b[i] & bad[i]; } } if (a[k] == 'E') { for (int i = 0; i < r; i++) { b[i] = (b[i] << 1); b[i] = b[i] & bad[i]; } } if (a[k] == 'N') { for (int i = 0; i < r - 1; i++) { b[i] = b[i + 1] & bad[i]; } b[r - 1] = re; } if (a[k] == 'S') { for (int i = r - 1; i > 0; i--) { b[i] = b[i - 1] & bad[i]; } b[0] = re; } if (a[k] == '?') { up[0] = re; down[r - 1] = re; for (int i = 0; i < r; i++) { if (i != 0) up[i] = b[i - 1]; if (i != r - 1) down[i] = b[i + 1]; left[i] = (b[i] >> 1); right[i] = (b[i] << 1); } for (int i = 0; i < r; i++) { b[i] = (((up[i] | down[i]) | right[i]) | left[i]); b[i] = b[i] & bad[i]; } } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) if (b[i][j]) ans++; } cout << ans; } int main() { ibase; int T = 1; // cin >> T; for (int i = 1; i <= T; i++) { // cout << "Case " << i << ": "; solve(); cout << el; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...