Submission #416838

# Submission time Handle Problem Language Result Execution time Memory
416838 2021-06-03T03:54:10 Z milleniumEeee Nautilus (BOI19_nautilus) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

// my defines
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define mk make_pair
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define prev prev132132131231

using namespace std;

const int MAXN = 505;
char tp[MAXN][MAXN];
bitset <505> dp[2][MAXN];
bitset <505> good[MAXN];

int toY[] = {-1, 0, 1, 0};
int toX[] = {0, 1, 0, -1};
int pos[1000];

signed main() {
	fastInp;
	int r, c, m;
	cin >> r >> c >> m;
	pos['N'] = 0;
	pos['E'] = 1;
	pos['S'] = 2;
	pos['W'] = 3;
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> tp[i][j];
			if (tp[i][j] == '.') {
				dp[0][i][j] = 1;		
				good[i][j] = 1;
			}
		}
	}
	string mp;
	cin >> mp;
	for (int xod = 1; xod <= m; xod++) {
		int cur = xod & 1;
		int prev = (cur ^ 1);
		for (int i = 1; i <= r; i++) {
			dp[cur][i] &= 0;
		}
		vector <int> cand;
		if (mp[xod] == '?') {
			for (int k = 0; k < 4; k++) {
				cand.pb(k);
			}
		} else {
			cand.pb(pos[mp[xod]]);
		}
		for (int i = 1; i <= r; i++) {
			for (int dir : cand) {
				if (dir == 0) {
					if (i > 1) {
						dp[cur][i - 1] |= (dp[prev][i] & good[i - 1]);
					}
				}
				if (dir == 1) {
					dp[cur][i] |= (dp[prev][i] >> 1);
				}
				if (dir == 2) {
					if (i < r) {
						dp[cur][i + 1] |= (dp[prev][i] & good[i + 1]);
					}
				}
				if (dir == 3) {
					dp[cur][i] |= (dp[prev][i] << 1);
				}
			}
		}
		for (int i = 1; i <= r; i++) {
			dp[cur][i] &= ();
		}
	}
	int ans = 0;
	for (int i = 1; i <= r; i++) {
		ans += dp[m % 2][i].count();
	}
	cout << ans << endl;
}
/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:56:23: warning: array subscript has type 'char' [-Wchar-subscripts]
   56 |    cand.pb(pos[mp[xod]]);
      |                       ^
nautilus.cpp:79:19: error: expected primary-expression before ')' token
   79 |    dp[cur][i] &= ();
      |                   ^