답안 #314315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314315 2020-10-19T16:29:47 Z shrek12357 Nautilus (BOI19_nautilus) C++14
66 / 100
12 ms 3072 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[105][105][105];
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 << counter << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 7 ms 1408 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Correct 9 ms 1408 KB Output is correct
5 Correct 6 ms 1440 KB Output is correct
6 Correct 4 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 7 ms 1408 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Correct 9 ms 1408 KB Output is correct
5 Correct 6 ms 1440 KB Output is correct
6 Correct 4 ms 1408 KB Output is correct
7 Correct 6 ms 1536 KB Output is correct
8 Correct 10 ms 1536 KB Output is correct
9 Correct 10 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 4 ms 1408 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 10 ms 1408 KB Output is correct
14 Correct 12 ms 1536 KB Output is correct
15 Correct 6 ms 1408 KB Output is correct
16 Correct 4 ms 1536 KB Output is correct
17 Correct 6 ms 1408 KB Output is correct
18 Correct 10 ms 1408 KB Output is correct
19 Correct 10 ms 1408 KB Output is correct
20 Correct 6 ms 1408 KB Output is correct
21 Correct 4 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1408 KB Output is correct
2 Correct 7 ms 1408 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Correct 9 ms 1408 KB Output is correct
5 Correct 6 ms 1440 KB Output is correct
6 Correct 4 ms 1408 KB Output is correct
7 Correct 6 ms 1536 KB Output is correct
8 Correct 10 ms 1536 KB Output is correct
9 Correct 10 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 4 ms 1408 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 10 ms 1408 KB Output is correct
14 Correct 12 ms 1536 KB Output is correct
15 Correct 6 ms 1408 KB Output is correct
16 Correct 4 ms 1536 KB Output is correct
17 Correct 6 ms 1408 KB Output is correct
18 Correct 10 ms 1408 KB Output is correct
19 Correct 10 ms 1408 KB Output is correct
20 Correct 6 ms 1408 KB Output is correct
21 Correct 4 ms 1408 KB Output is correct
22 Runtime error 8 ms 3072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Halted 0 ms 0 KB -