Submission #735757

# Submission time Handle Problem Language Result Execution time Memory
735757 2023-05-04T14:52:51 Z MODDI Nautilus (BOI19_nautilus) C++14
100 / 100
219 ms 716 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int r, c, n;
string str;
bitset<501> mat[501];
bitset<501> dp[2][501];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>r>>c>>n;
	memset(dp, 0, sizeof dp);
	memset(mat, 0, sizeof mat);
	for(int i = 0; i < r; i++){
		string s;
		cin>>s;
		for(int j = 0; j < c; j++){
			if(s[j] == '.'){
				mat[i][j] = 1;
				dp[0][i][j] = 1;
			}
		}
	}
	cin>>str;
//	for(int i = 0; i < r; i++){
//		for(int j = 0; j < c; j++){
//			cout<<dp[0][i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	cout<<endl;
//	assert(false);
	for(int step = 1; step <= n; step++){
		for(int i = 0; i < r; i++){
			dp[step%2][i] = 0;
		}
		for(int i = 0; i < r; i++){
			if (str[step - 1] == 'E' || str[step - 1] == '?') dp[step % 2][i] |= (dp[(step - 1) % 2][i] << 1 & mat[i]);
            if (str[step - 1] == 'W' || str[step - 1] == '?') dp[step % 2][i] |= (dp[(step - 1) % 2][i] >> 1 & mat[i]);
            if ((str[step - 1] == 'S' || str[step - 1] == '?') && i > 0) dp[step % 2][i] |= (dp[(step - 1) % 2][i - 1] & mat[i]);
            if ((str[step - 1] == 'N' || str[step - 1] == '?') && i < n - 1) dp[step % 2][i] |= (dp[(step - 1) % 2][i + 1] & mat[i]);
		}
	}
	ll ans = 0;
	for(int i = 0; i < r; i++){
		ans += dp[n%2][i].count();
	}
	cout<<ans<<endl;
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:19:27: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'class std::bitset<501>'; use assignment or value-initialization instead [-Wclass-memaccess]
   19 |  memset(mat, 0, sizeof mat);
      |                           ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
                 from nautilus.cpp:1:
/usr/include/c++/10/bitset:751:11: note: 'class std::bitset<501>' declared here
  751 |     class bitset
      |           ^~~~~~
# 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 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 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 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 132 ms 420 KB Output is correct
23 Correct 124 ms 672 KB Output is correct
24 Correct 126 ms 676 KB Output is correct
25 Correct 147 ms 600 KB Output is correct
26 Correct 133 ms 672 KB Output is correct
27 Correct 165 ms 708 KB Output is correct
28 Correct 175 ms 716 KB Output is correct
29 Correct 170 ms 672 KB Output is correct
30 Correct 175 ms 668 KB Output is correct
31 Correct 167 ms 676 KB Output is correct
32 Correct 202 ms 668 KB Output is correct
33 Correct 197 ms 672 KB Output is correct
34 Correct 219 ms 672 KB Output is correct
35 Correct 182 ms 668 KB Output is correct
36 Correct 196 ms 672 KB Output is correct