| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1367915 | dzhoz0 | Nautilus (BOI19_nautilus) | C++20 | 102 ms | 540 KiB |
/*
it could have been better :)
it will next time ;)
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>
const int MOD = 1'000'000'000 + 7;
void setIO(string name = "")
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#ifdef LOCAL
freopen("inp.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#else
if (!name.empty())
{
freopen((name + ".INP").c_str(), "r", stdin);
freopen((name + ".OUT").c_str(), "w", stdout);
}
#endif
}
const int MAXN = 500;
const int MAXK = 5000;
int n, m, l;
// bool a[MAXN + 5][MAXN + 5];
bitset<MAXN> a[MAXN];
bitset<MAXN> prv[MAXN];
bitset<MAXN> cur[MAXN];
map<char, pii> dirs = {
{'N', {-1, 0}},
{'W', {0, -1}},
{'S', {1, 0}},
{'E', {0, 1}}
};
void solve()
{
cin >> n >> m >> l;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
char c; cin >> c;
if(c == '#') a[i][j] = 0;
else a[i][j] = 1;
prv[i][j] = a[i][j];
}
}
string s; cin >> s;
for(int k = 0; k < l; k++) {
for(int i = 0; i < n; i++) {
vector<char> dd = {'N', 'S', 'W', 'E'};
if(s[k] != '?') dd = {s[k]};
// for(int j = 0; j < m; j++) {
// if(prv[i][j]) {
// for(char c : dd) {
// auto d = dirs[c];
// int ni = d.f + i, nj = d.s + j;
// if(ni >= 0 && ni < n && nj >= 0 && nj < m && a[ni][nj]) {
// cur[ni][nj] = 1;
// }
// }
// }
// }
for(char c : dd) {
if(c == 'N' && i > 0) {
cur[i - 1] |= prv[i];
}
if(c == 'W') {
cur[i] |= (prv[i] >> 1);
}
if(c == 'S' && i + 1 < n) {
cur[i + 1] |= prv[i];
}
if(c == 'E') {
cur[i] |= (prv[i] << 1);
}
}
}
swap(cur, prv);
for(int i = 0; i < n; i++) {
prv[i] &= a[i];
cur[i].reset();
}
}
int res = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
res += prv[i][j];
}
}
cout << res << '\n';
}
signed main()
{
setIO();
int t = 1;
// cin >> t;
while (t--)
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
