답안 #362913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362913 2021-02-04T17:28:59 Z aujasvit_datta Nautilus (BOI19_nautilus) C++14
0 / 100
4 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int> 
#define fr first
#define sc second
#define all(a) a.begin(),a.end()
int r,c,m;
string s;
string grid[700];

bool can_happen(int row, int col) {
	int cr = row, cc = col;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'W') {
			if(cc != 0 and grid[cr][cc - 1] != '#') {
				cc--;
			} else {
				return false;
			}
		} else if(s[i] == 'S') {
			if(cr != r and grid[cr + 1][cc] != '#') {
				cr++;
			} else {
				return false;
			}
		} else if(s[i] == 'N') {
			if(cr != 1 and grid[cr - 1][cc] != '#') {
				cr--;
			} else {
				return false;
			}
		} else if(s[i] == 'E') {
			if(cc != c - 1 and grid[cr][cc + 1] != '#') {
				cc++;
			} else {
				return false;
			}
		}
	}
	return true;
}

int count() {
	int ans = 0;
	for(int i = 1; i <= r; i++) {
		for(int j = 0; j < c; j++) {
			if(can_happen(i, j)) ans++;
		}
	}
	return ans;
}



signed main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> r >> c >> m;
	for(int i = 1; i <= r; i++) {
		cin >> grid[i];
	}
	cin >> s;

	cout << count() << endl;
	return 0;
}

Compilation message

nautilus.cpp: In function 'bool can_happen(long long int, long long int)':
nautilus.cpp:16:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < s.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -