답안 #860185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860185 2023-10-12T04:47:42 Z maks007 Nautilus (BOI19_nautilus) C++14
29 / 100
16 ms 5212 KB
#include "bits/stdc++.h"
 
using namespace std;
 
int dp[110][110][110];
 
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() + 1; i ++) {
		for(int posi = 1; posi <= n; posi ++) {
			for(int posj = 1; posj <= m; posj ++) {
				if(a[posi][posj] == '#') {
					dp[i][posi][posj] = 0;
					continue;
				}
				if(i == 1) {
					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 = 1; i <= n; i ++) {
		for(int j = 1; j <= m; j ++) ans += dp[str.size()+1][i][j];
	}
	cout << ans;
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i = 1; i <= str.size() + 1; i ++) {
      |                 ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 5208 KB Output is correct
2 Correct 12 ms 5208 KB Output is correct
3 Correct 11 ms 5192 KB Output is correct
4 Correct 10 ms 5212 KB Output is correct
5 Correct 6 ms 5188 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 5208 KB Output is correct
2 Correct 12 ms 5208 KB Output is correct
3 Correct 11 ms 5192 KB Output is correct
4 Correct 10 ms 5212 KB Output is correct
5 Correct 6 ms 5188 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Incorrect 16 ms 5212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 5208 KB Output is correct
2 Correct 12 ms 5208 KB Output is correct
3 Correct 11 ms 5192 KB Output is correct
4 Correct 10 ms 5212 KB Output is correct
5 Correct 6 ms 5188 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Incorrect 16 ms 5212 KB Output isn't correct
8 Halted 0 ms 0 KB -