답안 #314312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314312 2020-10-19T16:28:14 Z shrek12357 Nautilus (BOI19_nautilus) C++14
0 / 100
2 ms 768 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0); 

bool dp[50][50][50];
int r, c, m;

bool get(int x, int y, int k) {
	if (x >= r || x < 0 || y >= c || y < 0) {
		return false;
	}
	return dp[x][y][k - 1];
}

int main() {
	cin >> r >> c >> m;
	int grid[105][105];
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			char x;
			cin >> x;
			if (x == '.') {
				grid[i][j] = 1;
				dp[i][j][0] = true;
			}
			else {
				grid[i][j] = 0;
			}
		}
	}
	string s;
	cin >> s;
	for (int k = 1; k <= m; k++) {
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				if (grid[i][j] == 0) {
					dp[i][j][k] = false;
					continue;
				}
				if (s[k - 1] == 'W') {
					dp[i][j][k] = get(i, j + 1, k);
				}
				if (s[k - 1] == 'E') {
					dp[i][j][k] = get(i, j - 1, k);
				}
				if (s[k - 1] == 'N') {
					dp[i][j][k] = get(i + 1, j, k);
				}
				if (s[k - 1] == 'S') {
					dp[i][j][k] = get(i - 1, j, k);
				}
				if (s[k - 1] == '?') {
					dp[i][j][k] = get(i - 1, j, k) || get(i + 1, j, k) || get(i, j - 1, k) || get(i, j + 1, k);
				}
				//dp[i][j][k] &= dp[i][j][k - 1];
			}
		}
	}
	int counter = 0;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (dp[i][j][m]) {
				counter++;
			}
			cout << dp[i][j][m] << " ";
		}
		cout << endl;
	}
	cout << counter << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -