제출 #1148668

#제출 시각아이디문제언어결과실행 시간메모리
1148668arkanefuryNautilus (BOI19_nautilus)C++20
0 / 100
1 ms576 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #define F first #define S second #define int long long #define FOR(x, n, m, d) for(int x = n; x <= m; x += d) #define FORR(x, n, m, d) for(int x = n; x >= m; x -= d) #define nikita ios_base::sync_with_stdio(0), cin.tie(0); const int N = 500+150; int n,m,k,tt,ans,l, r, x, y, cnt, ko = 0; int b[N],a[N], sum, root[N], block = 620, d[N], c[N], par[N]; string s[N], str; void solve(){ nikita bitset<501>st[N], st1[N], ini[N]; cin >> n >> m >> k; FOR(i, 1, n, 1){ cin >> s[i]; FOR(j, 0, m-1, 1)if(s[i][j] == '.')st[i]|=(1 << j); } FOR(i, 1, n, 1)ini[i] = st[i]; cin >> str; FOR(i, 0, k-1, 1){ if(str[i] == 'N'){ FOR(j, 1, n-1, 1){ st[j] = st[j+1]; } st[n]&=0; } else if(str[i] == 'S'){ FORR(j, n, 2, 1)st[j] = st[j-1]; st[1] &= 0; } else if(str[i] == 'W'){ FOR(j, 1, n, 1){ st[j] >>= 1; } } else if(str[i] == 'E'){ FOR(j, 1, n, 1){ st[j] <<= 1; st[j][m] = 0; } } else{ FOR(j, 0, n + 1, 1) st1[j] &= 0; FOR(j, 1, n, 1)st1[j] = st[j]; FOR(j, 1, n, 1){ st[j] = (st[j] >> 1) | (st[j] << 1); st[j] |= st1[j-1], st[j] |= st1[j+1]; } } FOR(j, 1, n, 1)st[j] &= ini[j]; } ans = 0; FOR(i, 1, n, 1)ans += st[i].count(); cout << ans; } signed main() { nikita tt = 1; if(!tt)cin >> tt; FOR(i, 1, tt, 1){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...