# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1268298 | dex111222333444555 | Nautilus (BOI19_nautilus) | C++20 | 1 ms | 1348 KiB |
#include <bits/stdc++.h>
#define all(v) begin(v), end(v)
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
using namespace std;
const int MAXN = 505, MAXM = 5005;
int numRow, numCol, lenS;
string s;
bool M1;
bitset<MAXN> board[MAXN];
bitset<MAXN> dp[MAXN][MAXM];
void input(){
cin >> numRow >> numCol >> lenS;
for(int row = 1; row <= numRow; row++){
for(int col = 1; col <= numCol; col++){
char c; cin >> c;
board[row] <<= 1;
if (c == '.') board[row] |= 1;
}
dp[row][0] = board[row];
}
cin >> s;
s = '_' + s;
}
void solve(){
for(int pos = 1; pos <= lenS; pos++)
for(int row = 1; row <= numRow; row++){
if (s[pos] == 'D'){
dp[row][pos] = (dp[row][pos - 1] >> 1) & board[row];
}
if (s[pos] == 'T'){
dp[row][pos] = (dp[row][pos - 1] << 1) & board[row];
}
if (s[pos] == 'N'){
dp[row][pos] = (dp[row - 1][pos - 1]) & board[row];
}
if (s[pos] == 'B'){
dp[row][pos] = (dp[row + 1][pos - 1]) & board[row];
}
if (s[pos] == '?'){
dp[row][pos] =
((dp[row][pos - 1] >> 1)
| (dp[row][pos - 1] << 1)
| (dp[row - 1][pos - 1])
| (dp[row + 1][pos - 1])) & board[row];
}
}
int res = 0;
for(int row = 1; row <= numRow; row++) res += dp[row][lenS].count();
cout << res << '\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("TREASURE.inp", "r")){
freopen("TREASURE.inp", "r", stdin);
freopen("TREASURE.out", "w", stdout);
}
input();
solve();
cerr << TIME << ".s\n";
bool M2;
cerr << abs(&M1 - &M2) / 1024 / 1024 << " MB\n";
}
컴파일 시 표준 에러 (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... |