이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >
using namespace std;
const int N = 2e5 + 5;
int n, m, k;
string s;
char c[105][105];
bool used[105][105][105], can[105][105];
void dfs(int x, int y, int pos) {
if(min(x, y) == 0 || y > m || x > n) return;
if(c[x][y] == '#') return;
if(used[x][y][pos]) return;
used[x][y][pos] = 1;
if(pos == k) {
can[x][y] = 1;
return;
}
if(s[pos] == '?') {
dfs(x + 1, y, pos + 1);
dfs(x - 1, y, pos + 1);
dfs(x, y + 1, pos + 1);
dfs(x, y - 1, pos + 1);
}
if(s[pos] == 'W') {
dfs(x, y - 1, pos + 1);
} else if(s[pos] == 'E') {
dfs(x, y + 1, pos + 1);
} else if(s[pos] == 'N') {
dfs(x - 1, y, pos + 1);
} else if(s[pos] == 'S') {
dfs(x + 1, y, pos + 1);
}
}
main() {
//file("pieaters");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> c[i][j];
}
}
cin >> s;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
dfs(i, j, 0);
}
}
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(can[i][j]) {
++ans;
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
nautilus.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |