# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
725557 |
2023-04-17T16:18:41 Z |
pls33 |
Nautilus (BOI19_nautilus) |
C++17 |
|
657 ms |
2104 KB |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma region dalykai
template <typename F>
void _debug(F f)
{
f();
}
#ifndef _AAAAAAAAA
#define debug(x)
#else
#define debug(x) _debug(x)
#endif
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
using f80 = long double;
#pragma endregion
using grid_t = vector<string>;
bool inside(int i, int j, int row, int col)
{
return i >= 0 && i < row && j >= 0 && j < col;
}
int main()
{
#ifndef _AAAAAAAAA
ios_base::sync_with_stdio(false);
cin.tie(0);
#else
freopen("nautilus.in", "r", stdin);
#ifndef __linux__
atexit([]()
{
freopen("con", "r", stdin);
system("pause"); });
#endif
#endif
int row, col, n;
cin >> row >> col >> n;
grid_t grid(row);
for (auto &r : grid)
{
cin >> r;
}
string message;
cin >> message;
using set_t = bitset<5000>;
vector<set_t> cur, next;
vector<set_t> good(row);
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
good[i][j] = grid[i][j] == '.';
}
}
cur = good;
for (auto &c : message)
{
next = vector<set_t>(row);
for (int i = 0; i < row; i++)
{
// pasigailėk, Dieve, pasigailėk
switch (c)
{
case 'N':
{
if (i)
{
next[i - 1] |= cur[i];
}
break;
}
case 'S':
{
if (i < row - 1)
{
next[i + 1] |= cur[i];
}
break;
}
case 'E':
{
cur[i] <<= 1;
next[i] |= cur[i];
break;
}
case 'W':
{
cur[i] >>= 1;
next[i] |= cur[i];
break;
}
case '?':
{
if (i)
{
next[i - 1] |= cur[i];
}
if (i < row - 1)
{
next[i + 1] |= cur[i];
}
cur[i] <<= 1;
next[i] |= cur[i];
cur[i] >>= 2;
next[i] |= cur[i];
break;
}
}
}
for (int i = 0; i < row; i++)
{
next[i] &= good[i];
}
swap(next, cur);
}
size_t total = 0;
for (int i = 0; auto &r : cur)
{
debug([&]()
{
string s = r.to_string();
reverse(s.begin(), s.end());
s.erase(s.begin() + col, s.end());
for (int j = 0; j < col; j++)
{
if (grid[i][j] == '#')
{
s[j] = '#';
}
if (s[j] == '0')
{
s[j] = '.';
}
}
cout << s << '\n';
//
});
total += r.count();
i++;
}
cout << total << '\n';
return 0;
}
Compilation message
nautilus.cpp:9: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
9 | #pragma region dalykai
|
nautilus.cpp:44: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
44 | #pragma endregion
|
nautilus.cpp: In function 'int main()':
nautilus.cpp:163:21: warning: range-based 'for' loops with initializer only available with '-std=c++2a' or '-std=gnu++2a'
163 | for (int i = 0; auto &r : cur)
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
3 ms |
468 KB |
Output is correct |
13 |
Correct |
3 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
468 KB |
Output is correct |
16 |
Correct |
3 ms |
468 KB |
Output is correct |
17 |
Correct |
4 ms |
576 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
3 ms |
468 KB |
Output is correct |
13 |
Correct |
3 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
468 KB |
Output is correct |
16 |
Correct |
3 ms |
468 KB |
Output is correct |
17 |
Correct |
4 ms |
576 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
3 ms |
468 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
388 ms |
1836 KB |
Output is correct |
23 |
Correct |
394 ms |
1836 KB |
Output is correct |
24 |
Correct |
357 ms |
1836 KB |
Output is correct |
25 |
Correct |
358 ms |
1880 KB |
Output is correct |
26 |
Correct |
366 ms |
1836 KB |
Output is correct |
27 |
Correct |
506 ms |
1836 KB |
Output is correct |
28 |
Correct |
521 ms |
1836 KB |
Output is correct |
29 |
Correct |
513 ms |
1836 KB |
Output is correct |
30 |
Correct |
506 ms |
1836 KB |
Output is correct |
31 |
Correct |
516 ms |
1836 KB |
Output is correct |
32 |
Correct |
625 ms |
1836 KB |
Output is correct |
33 |
Correct |
657 ms |
2092 KB |
Output is correct |
34 |
Correct |
651 ms |
2092 KB |
Output is correct |
35 |
Correct |
639 ms |
2080 KB |
Output is correct |
36 |
Correct |
628 ms |
2104 KB |
Output is correct |