제출 #1183433

#제출 시각아이디문제언어결과실행 시간메모리
1183433petezaNautilus (BOI19_nautilus)C++20
100 / 100
136 ms516 KiB
#include <bits/stdc++.h> using namespace std; using bs = bitset<500>; int r, c, m; string str; deque<bs> deq; bs toand[505]; int main() { cin.tie(0) -> sync_with_stdio(0); cin >> r >> c >> m; for(int i=0;i<r;i++) { cin >> str; for(int j=0;j<c;j++) { if(str[j] == '.') toand[i][j] = 1; else toand[i][j] = 0; } deq.emplace_back(toand[i]); } cin >> str; //reverse(str.begin(), str.end()); for(auto &e:str) { if(e == 'W' || e == 'E') { for(auto &E:deq) { if(e == 'W') E >>= 1; else E <<= 1; } } else if(e == 'N' || e == 'S') { if(e == 'S') {deq.pop_back(); deq.push_front({});} else {deq.pop_front(); deq.push_back({});} } else { auto last = bs(); for(int i=0;i<r-1;i++) { last = (deq[i] >> 1) | (deq[i] << 1) | last | (deq[i+1]); swap(last, deq[i]); } deq[r-1] = last | (deq[r-1] >> 1) | (deq[r-1] << 1); } for(int i=0;i<r;i++) deq[i] &= toand[i]; } int ans = 0; for(int i=0;i<r;i++) { ans += deq[i].count(); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...