Submission #148111

# Submission time Handle Problem Language Result Execution time Memory
148111 2019-08-31T13:59:31 Z WhipppedCream Nautilus (BOI19_nautilus) C++17
100 / 100
297 ms 1400 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 505;
const int maxs = 50005;
const int sz = 500*500;
int n, m, k;
char arr[maxn][maxn];
char dir[maxs];

int main()
{	
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 0; i< n; i++) scanf("%s", arr[i]);
	bitset<sz> mask;
	bitset<sz> mright, mleft; 
	mright.set(); mleft.set();
	for(int i = 0; i< n; i++)
	{
		for(int j = 0; j< m; j++)
		{
			if(arr[i][j] == '#') mask[i*m+j] = 0;
			else mask[i*m+j] = 1;
			if(j == 0) mleft[i*m+j] = 0;
			if(j == m-1) mright[i*m+j] = 0;
		}
	}
	bitset<sz> dp;
	for(int i = 0; i< n; i++)
	{
		for(int j = 0; j< m; j++)
		{
			dp[i*m+j] = 1;
		}
	}
	dp &= mask;
	// printf("%d\n", dp.count());
	scanf("%s", dir);
	for(int i = 0; i< k; i++)
	{
		if(dir[i] == 'N')
		{
			dp = dp>>m;
		}
		else if(dir[i] == 'S')
		{
			dp = dp<<m;
		}
		else if(dir[i] == 'E')
		{
			dp = (dp<<1)&mleft;
		}
		else if(dir[i] == 'W') 
		{
			dp = (dp>>1)&mright;
		}
		else 
		{
			dp = (dp>>m)|(dp<<m)|((dp<<1)&mleft)|((dp>>1)&mright);
		}
		dp &= mask;
	}
	printf("%d\n", (int) dp.count());
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i< n; i++) scanf("%s", arr[i]);
                            ~~~~~^~~~~~~~~~~~~~
nautilus.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", dir);
  ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 4 ms 664 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 4 ms 664 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 6 ms 888 KB Output is correct
8 Correct 6 ms 888 KB Output is correct
9 Correct 6 ms 888 KB Output is correct
10 Correct 6 ms 888 KB Output is correct
11 Correct 6 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 8 ms 888 KB Output is correct
15 Correct 8 ms 888 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 8 ms 760 KB Output is correct
18 Correct 9 ms 760 KB Output is correct
19 Correct 9 ms 888 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 9 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 4 ms 664 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 6 ms 888 KB Output is correct
8 Correct 6 ms 888 KB Output is correct
9 Correct 6 ms 888 KB Output is correct
10 Correct 6 ms 888 KB Output is correct
11 Correct 6 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 8 ms 888 KB Output is correct
15 Correct 8 ms 888 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 8 ms 760 KB Output is correct
18 Correct 9 ms 760 KB Output is correct
19 Correct 9 ms 888 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 9 ms 760 KB Output is correct
22 Correct 159 ms 1384 KB Output is correct
23 Correct 156 ms 1376 KB Output is correct
24 Correct 159 ms 1400 KB Output is correct
25 Correct 155 ms 1272 KB Output is correct
26 Correct 154 ms 1272 KB Output is correct
27 Correct 252 ms 1400 KB Output is correct
28 Correct 241 ms 1384 KB Output is correct
29 Correct 234 ms 1380 KB Output is correct
30 Correct 239 ms 1376 KB Output is correct
31 Correct 237 ms 1372 KB Output is correct
32 Correct 294 ms 1272 KB Output is correct
33 Correct 295 ms 1272 KB Output is correct
34 Correct 297 ms 1268 KB Output is correct
35 Correct 297 ms 1272 KB Output is correct
36 Correct 296 ms 1272 KB Output is correct