Submission #860183

# Submission time Handle Problem Language Result Execution time Memory
860183 2023-10-12T04:44:25 Z maks007 Nautilus (BOI19_nautilus) C++14
0 / 100
16 ms 8280 KB
#include "bits/stdc++.h"
 
using namespace std;
 
int dp[100][100][100];
 
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];
	for(int i = 0; i < n; i ++) {
		cin >> a[i];
	}
	string str;
	cin >> str;
	for(int i = 0; i <= str.size(); i ++) {
		for(int posi = 0; posi < n; posi ++) {
			for(int posj = 0; posj < m; posj ++) {
				if(a[posi][posj] == '#') {
					dp[i][posi][posj] = 0;
					continue;
				}
				if(i == 0) {
					dp[i][posi][posj]=1;
				}else {
					if(str[i-1] == '?') {
						char ch = 'E';
						dp[i][posi][posj] += dp[i-1][posi+it[ch]][posj+jt[ch]];
						ch = 'W';
						dp[i][posi][posj] += dp[i-1][posi+it[ch]][posj+jt[ch]];
						ch = 'N';
						dp[i][posi][posj] += dp[i-1][posi+it[ch]][posj+jt[ch]];
						ch = 'S';
						dp[i][posi][posj] += dp[i-1][posi+it[ch]][posj+jt[ch]];
					}else {
						char ch = op[str[i-1]];
						dp[i][posi][posj] = dp[i-1][posi+it[ch]][posj+jt[ch]];
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < m; j ++) ans += dp[str.size()][i][j];
	}
	cout << ans;
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i <= str.size(); i ++) {
      |                 ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 8280 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 8280 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 8280 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -