제출 #1091741

#제출 시각아이디문제언어결과실행 시간메모리
1091741gygNautilus (BOI19_nautilus)C++17
100 / 100
41 ms604 KiB
#pragma GCC optimize("Ofast", "unroll-loops") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define arr array #define vct vector #define bset bitset const int MX_R = 5e2 + 5, MX_C = 5e2 + 5, MX_N = 5e3 + 5; int r, c, n; arr<bset<MX_C>, MX_R> fr; arr<char, MX_N> mv; arr<arr<bset<MX_C>, MX_R>, 2> ps; void cmp() { for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) ps[0][i][j] = fr[i][j]; for (int i = 1; i <= n; i++) { int prty = i % 2, opp_prty = (i + 1) % 2; if (mv[i] == 'W') { for (int j = 1; j <= r; j++) ps[prty][j] = fr[j] & (ps[opp_prty][j] >> 1); } if (mv[i] == 'E') { for (int j = 1; j <= r; j++) ps[prty][j] = fr[j] & (ps[opp_prty][j] << 1); } if (mv[i] == 'S') { for (int j = 1; j <= r; j++) ps[prty][j] = fr[j] & ps[opp_prty][j - 1]; } if (mv[i] == 'N') { for (int j = 1; j <= r; j++) ps[prty][j] = fr[j] & ps[opp_prty][j + 1]; } if (mv[i] == '?') { for (int j = 1; j <= r; j++) ps[prty][j] = fr[j] & ((ps[opp_prty][j] >> 1) | (ps[opp_prty][j] << 1) | ps[opp_prty][j - 1] | ps[opp_prty][j + 1]); } // cout << mv[i] << ": " << "----------------" << endl; // for (int j = 1; j <= r; j++) { // for (int k = 1; k <= c; k++) cout << ps[prty][j][k]; // cout << endl; // } } } int main() { // freopen("nt.in", "r", stdin); cin.sync_with_stdio(false), cin.tie(0); cin >> r >> c >> n; for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { char x; cin >> x; fr[i][j] = (x == '.'); } } for (int i = 1; i <= n; i++) cin >> mv[i]; cmp(); int ans = 0; for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) ans += ps[n % 2][i][j]; cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...