제출 #1329279

#제출 시각아이디문제언어결과실행 시간메모리
1329279floNautilus (BOI19_nautilus)C++20
100 / 100
215 ms158564 KiB
#include <bits/stdc++.h>
#define task "treasure"
#define ll long long
#define multitest 0
using namespace std;

const int N = 500, K = 5000;

bitset<N+5> a[N+5], dp[K+5][N+5];

void flo(int ID) {
	int n, m, k; cin >> n >> m >> k;
	
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			char c; cin >> c;
			
			if (c == '.') {
				a[x].set(y), dp[0][x].set(y);
			}
		}
	}
	
	for (int i = 1; i <= k; i++) {
		char c; cin >> c;
		
		if (c == 'E' || c == '?') {
			for (int x = 0; x < n; x++) {
				dp[i][x] |= dp[i-1][x]<<1;
			}
		}
		if (c == 'W' || c == '?') {
			for (int x = 0; x < n; x++) {
				dp[i][x] |= dp[i-1][x]>>1;
			}
		}
		if (c == 'S' || c == '?') {
			for (int x = 1; x < n; x++) {
				dp[i][x] |= dp[i-1][x-1];
			}
		}
		if (c == 'N' || c == '?') {
			for (int x = 0; x < n-1; x++) {
				dp[i][x] |= dp[i-1][x+1];
			}
		}
		
		for (int x = 0; x < n; x++) {
			dp[i][x] &= a[x];
		}
	}
	
	int ans = 0;
	
	for (int x = 0; x < n; x++) {
		ans += dp[k][x].count();
	}
	
	cout << ans << "\n";
}

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

	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}

	int TCS = 1, ID = 1;

	if (multitest) {
		cin >> TCS;
	}

	while (TCS--) flo(ID++);

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp: In function 'int main()':
nautilus.cpp:67:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |                 freopen(task".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:68:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |                 freopen(task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...