제출 #1335700

#제출 시각아이디문제언어결과실행 시간메모리
1335700blackscreen1Nautilus (BOI19_nautilus)C++20
100 / 100
101 ms544 KiB
#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define ll long long
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1))
#define pll pair<ll, ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
ll n, m, q;
bitset<505> bs[505], bs2[505], bs3[505], bs4[505];
char c;
string s;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> q;
	iloop(0, n) jloop(0, m) {
		cin >> c;
		bs[i][j] = bs2[i][j] = (c == '.');
	}
	cin >> s;
	for (auto it : s) {
		if (it == 'N') {
			iloop(0, n-1) swap(bs[i], bs[i+1]);
			bs[n-1] &= bs4[n-1];
		}
		else if (it == 'S') {
			iloop(n-1, 0) swap(bs[i], bs[i-1]);
			bs[0] &= bs4[0];
		}
		else if (it == 'E') {
			iloop(0, n) bs[i] <<= 1;
		}
		else if (it == 'W') {
			iloop(0, n) bs[i] >>= 1;
		}
		else {
			iloop(0, n) bs3[i] &= bs4[i];
			iloop(0, n) {
				if (i) bs3[i-1] |= bs[i];
				if (i < n-1) bs3[i+1] |= bs[i];
				bs3[i] |= (bs[i]<<1) | (bs[i]>>1);
			}
			swap(bs3, bs);
		}
		iloop(0, n) bs[i] &= bs2[i];
	}
	ll cans = 0;
	iloop(0, n) jloop(0, m) cans += bs[i][j];
	cout << cans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...