Submission #243342

# Submission time Handle Problem Language Result Execution time Memory
243342 2020-06-30T23:49:35 Z Lawliet Nautilus (BOI19_nautilus) C++17
100 / 100
283 ms 768 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 510;
const int MAXT = 5010;

int n, m, k;

string s;

bitset<MAXN> dp[MAXN][2], v[MAXN];

int main()
{
	cin >> n >> m >> k;

	for(int i = 1 ; i <= n ; i++)
	{
		for(int j = 1 ; j <= m ; j++)
		{
			char c;
			scanf(" %c",&c);

			if( c == '.' ) v[i][j] = 1;
		}
	}

	cin >> s;

	for(int i = 1 ; i <= n ; i++)
		dp[i][1] = v[i];

	for(int t = 0 ; t < k ; t++)
	{
		for(int i = 1 ; i <= n ; i++)
		{
			dp[i][t%2].reset();

			if( s[t] == 'N' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | dp[i + 1][1 - t%2] );
			if( s[t] == 'S' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | dp[i - 1][1 - t%2] );
			if( s[t] == 'E' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | ( dp[i][1 - t%2] << 1 ) );
			if( s[t] == 'W' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | ( dp[i][1 - t%2] >> 1 ) );

			dp[i][t%2] = ( dp[i][t%2] & v[i] );
		}
	}

	int ans = 0;

	for(int i = 1 ; i <= n ; i++)
		ans += dp[i][1 - k%2].count();

	printf("%d\n",ans);
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&c);
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 7 ms 360 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 256 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 7 ms 360 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 256 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 170 ms 768 KB Output is correct
23 Correct 169 ms 640 KB Output is correct
24 Correct 168 ms 760 KB Output is correct
25 Correct 166 ms 760 KB Output is correct
26 Correct 164 ms 640 KB Output is correct
27 Correct 233 ms 760 KB Output is correct
28 Correct 240 ms 752 KB Output is correct
29 Correct 233 ms 640 KB Output is correct
30 Correct 233 ms 760 KB Output is correct
31 Correct 233 ms 640 KB Output is correct
32 Correct 282 ms 640 KB Output is correct
33 Correct 283 ms 640 KB Output is correct
34 Correct 283 ms 640 KB Output is correct
35 Correct 281 ms 640 KB Output is correct
36 Correct 283 ms 640 KB Output is correct