답안 #930181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930181 2024-02-18T20:54:05 Z vjudge1 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 860 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define emb emplace_back
#define emc emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
template <class type_key, class type_val>
using um = unordered_map<type_key, type_val>;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

	int n, m, k;
	cin >> n >> m >> k;

	bitset<501> dp[501];
	char c[n+1][m+1];
	for( int i = 1; i <= n; i++ ) {
		for( int j = 1; j <= m; j++ ) {
			cin >> c[i][j];
			if( c[i][j] == '.') dp[i][j] = 1;
			else dp[i][j] = 0;
		}
	}

	char s[k+1];
	for( int i = 1; i <= k; i++ ) {
		cin >> s[i];
	}

	int ans;
	for( int id = 1; id <= k; id++ ) {
		bitset<501> d[501];
		ans = 0;
		for( int i = 1; i <= n; i++ ) {
			for( int j = 1; j <= m; j++ ) {
				d[i][j] = 0;
				if( c[i][j] != '#') {
					if( (s[id] == '?' || s[id] == 'N') && i < n ) {
						d[i][j] = (d[i][j]|dp[i+1][j]);
					}
					if( (s[id] == '?' || s[id] == 'S') && i > 1 ) {
						d[i][j] = (d[i][j]|dp[i-1][j]);
					}
					if( (s[id] == '?' || s[id] == 'E') && j > 1 ) {
						d[i][j] = (d[i][j]|dp[i][j-1]);
					}
					if( (s[id] == '?' || s[id] == 'W') && j < m ) {
						d[i][j] = (d[i][j]|dp[i][j+1]);
					}
				}
			}
		}
		for( int i = 1; i <= n; i++ ) {
			for( int j = 1; j <= m; j++ ) {
				dp[i][j] = d[i][j];
				if( dp[i][j] == 1 ) ans++;
			}
		}
	}
	cout << ans;

return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:75:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   75 |  cout << ans;
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 7 ms 536 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 7 ms 536 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 9 ms 348 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 8 ms 524 KB Output is correct
13 Correct 11 ms 348 KB Output is correct
14 Correct 14 ms 348 KB Output is correct
15 Correct 6 ms 348 KB Output is correct
16 Correct 5 ms 524 KB Output is correct
17 Correct 9 ms 348 KB Output is correct
18 Correct 11 ms 540 KB Output is correct
19 Correct 12 ms 344 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 7 ms 536 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 9 ms 348 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 8 ms 524 KB Output is correct
13 Correct 11 ms 348 KB Output is correct
14 Correct 14 ms 348 KB Output is correct
15 Correct 6 ms 348 KB Output is correct
16 Correct 5 ms 524 KB Output is correct
17 Correct 9 ms 348 KB Output is correct
18 Correct 11 ms 540 KB Output is correct
19 Correct 12 ms 344 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Execution timed out 1057 ms 860 KB Time limit exceeded
23 Halted 0 ms 0 KB -