Submission #730662

# Submission time Handle Problem Language Result Execution time Memory
730662 2023-04-26T08:56:08 Z gagik_2007 Nautilus (BOI19_nautilus) C++17
100 / 100
128 ms 972 KB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
#include <bitset>
using namespace std;

typedef long long ll;
typedef long double ld;

#pragma GCC optimize("Ofast")

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 507;
const ll LG = 21;
ll n, m, k;
char a[N][N];
string s;
bitset<N> dp[N];
bitset<N> lst[N];
bitset<N> b[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			if (a[i][j] == '.') {
				b[i][j] = true;
				dp[i][j] = true;
			}
		}
	}
	cin >> s;
	for (int c = 0; c < s.size(); c++) {
		for (int i = 1; i <= n; i++) {
			lst[i] = dp[i];
			dp[i] = 0;
		}
		for (int i = 1; i <= n; i++) {
			if (s[c] == 'N' || s[c] == '?') {
				dp[i - 1] |= (lst[i] & b[i - 1]);
			}
			if (s[c] == 'E' || s[c] == '?') {
				dp[i] |= ((lst[i] << 1) & b[i]);
			}
			if (s[c] == 'S' || s[c] == '?') {
				dp[i + 1] |= (lst[i] & b[i + 1]);
			}
			if (s[c] == 'W' || s[c] == '?') {
				dp[i] |= ((lst[i] >> 1) & b[i]);
			}
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cnt += dp[i][j];
		}
	}
	cout << cnt << endl;
}

/// ---- - --------  ------ -------- -- - - -
/// Just a reminder. Ubuntu password is I O I
/// ---- - --------  ------ -------- -- - - -

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |  for (int c = 0; c < s.size(); c++) {
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 91 ms 724 KB Output is correct
23 Correct 87 ms 924 KB Output is correct
24 Correct 88 ms 916 KB Output is correct
25 Correct 92 ms 972 KB Output is correct
26 Correct 98 ms 864 KB Output is correct
27 Correct 109 ms 852 KB Output is correct
28 Correct 111 ms 844 KB Output is correct
29 Correct 108 ms 912 KB Output is correct
30 Correct 114 ms 928 KB Output is correct
31 Correct 113 ms 900 KB Output is correct
32 Correct 112 ms 912 KB Output is correct
33 Correct 119 ms 916 KB Output is correct
34 Correct 128 ms 916 KB Output is correct
35 Correct 121 ms 840 KB Output is correct
36 Correct 116 ms 892 KB Output is correct