답안 #712645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
712645 2023-03-19T11:33:20 Z TimDee Nautilus (BOI19_nautilus) C++17
100 / 100
20 ms 956 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2,popcnt")

//#define int long long
//#define int int16_t
#define forn(i,n) for(size_t i=0;i<n;++i)
#define pb push_back
#define all(x)  x.begin(),x.end()
#define pi pair<int,int>
#define f first
#define s second

const int N=502, M=502;

bitset<M> dp[2][N];
bitset<M> ok[N];

void solve() {

	int n,m,k; cin>>n>>m>>k;
	vector<string> a(n);
	forn(i,n) cin>>a[i];
	string s; cin>>s;
	forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);

	bool u,d,l,r,t;
	forn(it,k) {
		char c=s[it];
		int b=it&1;
		for (int i=1; i<=n; ++i) {
			if (c=='?') {
				dp[b^1][i]=ok[i]&((dp[b][i]>>1)|(dp[b][i]<<1)|dp[b][i+1]|dp[b][i-1]);
			} else {
				if (c=='N') dp[b^1][i]=ok[i]&dp[b][i+1];
				if (c=='S') dp[b^1][i]=ok[i]&dp[b][i-1];
				if (c=='W') dp[b^1][i]=ok[i]&(dp[b][i]>>1);
				if (c=='E') dp[b^1][i]=ok[i]&(dp[b][i]<<1);
			}
		}
		
	}

	int32_t ans=0;
	forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
	cout<<ans;

}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t=1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

Compilation message

nautilus.cpp: In function 'void solve()':
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   26 |  forn(i,n) cin>>a[i];
      |       ~~~                          
nautilus.cpp:26:2: note: in expansion of macro 'forn'
   26 |  forn(i,n) cin>>a[i];
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |       ~~~                          
nautilus.cpp:28:2: note: in expansion of macro 'forn'
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |                 ~~~                
nautilus.cpp:28:12: note: in expansion of macro 'forn'
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |            ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   31 |  forn(it,k) {
      |       ~~~~                         
nautilus.cpp:31:2: note: in expansion of macro 'forn'
   31 |  forn(it,k) {
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |       ~~~                          
nautilus.cpp:48:2: note: in expansion of macro 'forn'
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |                 ~~~                
nautilus.cpp:48:12: note: in expansion of macro 'forn'
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |            ^~~~
nautilus.cpp:30:7: warning: unused variable 'u' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |       ^
nautilus.cpp:30:9: warning: unused variable 'd' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |         ^
nautilus.cpp:30:11: warning: unused variable 'l' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |           ^
nautilus.cpp:30:13: warning: unused variable 'r' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |             ^
nautilus.cpp:30:15: warning: unused variable 't' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |               ^
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 336 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 332 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 336 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 332 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 13 ms 852 KB Output is correct
23 Correct 14 ms 852 KB Output is correct
24 Correct 14 ms 876 KB Output is correct
25 Correct 18 ms 836 KB Output is correct
26 Correct 13 ms 852 KB Output is correct
27 Correct 20 ms 956 KB Output is correct
28 Correct 17 ms 852 KB Output is correct
29 Correct 17 ms 852 KB Output is correct
30 Correct 17 ms 852 KB Output is correct
31 Correct 17 ms 848 KB Output is correct
32 Correct 19 ms 852 KB Output is correct
33 Correct 19 ms 948 KB Output is correct
34 Correct 19 ms 852 KB Output is correct
35 Correct 18 ms 948 KB Output is correct
36 Correct 18 ms 852 KB Output is correct