# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
860214 | maks007 | Nautilus (BOI19_nautilus) | C++14 | 1091 ms | 2648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
int dp[510][510];
int pref[510][510];
signed main () {
map <char,char> op;
map <char,int> it, jt;
op['E'] = 'W';
op['W'] = 'E';
op['S'] = 'N';
op['N'] = 'S';
it['E'] = 0;
it['W'] = 0;
it['S'] = 1;
it['N'] = -1;
jt['E'] = 1;
jt['W'] = -1;
jt['S'] = 0;
jt['N'] = 0;
int n, m, c;
cin >> n >> m >> c;
string a[n+1];
for(int i = 1; i <= n; i ++) {
cin >> a[i];
a[i] = ' ' + a[i];
}
string str;
cin >> str;
str = ' ' + str;
for(int i = 1; i <= str.size(); i ++) {
for(int posi = 1; posi <= n; posi ++) {
for(int posj = 1; posj <= m; posj ++) {
if(a[posi][posj] == '#') {
dp[posi][posj] = 0;
continue;
}
if(i == 1) {
dp[posi][posj]=1;
}else {
if(str[i-1] == '?') {
char ch = 'E';
dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
ch = 'W';
dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
ch = 'N';
dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
ch = 'S';
dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
}else {
char ch = op[str[i-1]];
dp[posi][posj] |= pref[posi+it[ch]][posj+jt[ch]];
}
}
}
}
for(int posi = 1; posi <= n; posi ++) {
for(int posj = 1; posj <= m; posj ++) {
pref[posi][posj] = dp[posi][posj];
dp[posi][posj] = 0;
}
}
}
// cout << "\n";
int ans = 0;
// for(int ss = 1; ss <= str.size(); ss ++) {
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
// cout << dp[str.size()][i][j] << " ";
ans += pref[i][j];
}
// cout << "\n";
}
// cout << "\n";
// }
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |