Submission #860214

# Submission time Handle Problem Language Result Execution time Memory
860214 2023-10-12T07:42:22 Z maks007 Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 2648 KB
#include "bits/stdc++.h"
 
using namespace std;
 
int dp[510][510];
int pref[510][510];
 
signed main () {
	map <char,char> op;
	map <char,int> it, jt;
	op['E'] = 'W';
	op['W'] = 'E';
	op['S'] = 'N';
	op['N'] = 'S';
	it['E'] = 0;
	it['W'] = 0;
	it['S'] = 1;
	it['N'] = -1;
 
	jt['E'] = 1;
	jt['W'] = -1;
	jt['S'] = 0;
	jt['N'] = 0;
	int n, m, c;
	cin >> n >> m >> c;
	string a[n+1];
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		a[i] = ' ' + a[i];
	}
	string str;
	cin >> str;
	str = ' ' + str;
	for(int i = 1; i <= str.size(); i ++) {
		for(int posi = 1; posi <= n; posi ++) {
			for(int posj = 1; posj <= m; posj ++) {
				if(a[posi][posj] == '#') {
					dp[posi][posj] = 0;
					continue;
				}
				if(i == 1) {
					dp[posi][posj]=1;
				}else {
					if(str[i-1] == '?') {
						char ch = 'E';
						dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
						ch = 'W';
						dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
						ch = 'N';
						dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
						ch = 'S';
						dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
					}else {
						char ch = op[str[i-1]];
						dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
					}
				}
			}
		}
		for(int posi = 1; posi <= n; posi ++) {
			for(int posj = 1; posj <= m; posj ++) {
				pref[posi][posj] = dp[posi][posj];
				dp[posi][posj] = 0;
			}
		}
	}
	// cout << "\n";
	int ans = 0;
	// for(int ss = 1; ss <= str.size(); ss ++) {
		for(int i = 1; i <= n; i ++) {
			for(int j = 1; j <= m; j ++) {
				// cout << dp[str.size()][i][j] << " ";
				ans += pref[i][j];
			}
			// cout << "\n";
		}
		// cout << "\n";
	// }
	cout << ans;
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i = 1; i <= str.size(); i ++) {
      |                 ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 860 KB Output is correct
2 Correct 10 ms 852 KB Output is correct
3 Correct 11 ms 852 KB Output is correct
4 Correct 9 ms 860 KB Output is correct
5 Correct 6 ms 860 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 860 KB Output is correct
2 Correct 10 ms 852 KB Output is correct
3 Correct 11 ms 852 KB Output is correct
4 Correct 9 ms 860 KB Output is correct
5 Correct 6 ms 860 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 16 ms 860 KB Output is correct
8 Correct 18 ms 852 KB Output is correct
9 Correct 12 ms 860 KB Output is correct
10 Correct 7 ms 852 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 23 ms 600 KB Output is correct
13 Correct 21 ms 600 KB Output is correct
14 Correct 18 ms 860 KB Output is correct
15 Correct 9 ms 860 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 28 ms 860 KB Output is correct
18 Correct 25 ms 600 KB Output is correct
19 Correct 18 ms 860 KB Output is correct
20 Correct 11 ms 852 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 860 KB Output is correct
2 Correct 10 ms 852 KB Output is correct
3 Correct 11 ms 852 KB Output is correct
4 Correct 9 ms 860 KB Output is correct
5 Correct 6 ms 860 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 16 ms 860 KB Output is correct
8 Correct 18 ms 852 KB Output is correct
9 Correct 12 ms 860 KB Output is correct
10 Correct 7 ms 852 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 23 ms 600 KB Output is correct
13 Correct 21 ms 600 KB Output is correct
14 Correct 18 ms 860 KB Output is correct
15 Correct 9 ms 860 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 28 ms 860 KB Output is correct
18 Correct 25 ms 600 KB Output is correct
19 Correct 18 ms 860 KB Output is correct
20 Correct 11 ms 852 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Execution timed out 1091 ms 2648 KB Time limit exceeded
23 Halted 0 ms 0 KB -