Submission #529668

# Submission time Handle Problem Language Result Execution time Memory
529668 2022-02-23T10:22:34 Z c28dnv9q3 Nautilus (BOI19_nautilus) C++17
29 / 100
3 ms 204 KB
#include <vector>
#include <iostream>

int main() {
	int R, C, M;
	scanf("%d%d%d", &R, &C, &M);
	std::vector<std::vector<char>> map(R);
	for (int i = 0; i < R; i++) {
		map[i].resize(C);
	}
	getchar();
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			char x;
			x = getchar();
			map[i][j] = x;
		}
		getchar();
	}
	std::vector<int> commands(M);
	for (int i = 0; i < M; i++) {
		char c = getchar();
		int x = -1;
		switch (c) {
		case 'N': x = 0; break;
		case 'S': x = 1; break;
		case 'E': x = 2; break;
		case 'W': x = 3; break;
		}
		commands[i] = x;
	}

	int counter = 0;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			int x = i, y = j;
			for (int z = M - 1; z >= -1; z--) {
				if (x < 0 || y < 0 || x >= R || y >= C) {
					goto END;
				}
				if (map[x][y] == '#') {
					goto END;
				}
				if(z==-1){
					counter++;
					goto END;
				}
				else {
					int c = commands[z];
					switch (c){
					case 0:x++; break;
					case 1:x--; break;
					case 2:y--; break;
					case 3:y++; break;
					}
				}
			}
		END:counter = counter;
		}
	}
	std::cout << counter;
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d%d%d", &R, &C, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 3 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 3 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -