Submission #725542

# Submission time Handle Problem Language Result Execution time Memory
725542 2023-04-17T15:16:35 Z pls33 Nautilus (BOI19_nautilus) C++17
0 / 100
10 ms 340 KB
#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;

    map<char, int> command;
    command['N'] = 0;
    command['S'] = 1;
    command['E'] = 2;
    command['W'] = 3;
    command['?'] = 4;

    for (auto &c : message)
    {
        c = (char)command[c];
    }

    using set_t = bitset<100>;

    vector<set_t> cur(row), next;
    for (auto &r : cur)
    {
        r.set();
    }

    const vi16 dr = {1, -1, 0, 0};
    const vi16 dc = {0, 0, 1, -1};

    for (auto &c : message)
    {
        next = vector<set_t>(row);
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (!cur[i][j] || grid[i][j] == '#')
                {
                    continue;
                }

                for (int k = (c == 4) ? 0 : c; (c == 4) ? k < 4 : k < c + 1; k++)
                {
                    int a = i + dr[k];
                    int b = j + dc[k];

                    if (inside(a, b, row, col) && grid[a][b] != '#')
                    {
                        next[a][b] = true;
                    }
                }
            }
        }

        swap(next, cur);
    }

    size_t total = 0;
    for (auto &r : cur)
    {
        total += r.count();
    }

    cout << total << '\n';

    return 0;
}

Compilation message

nautilus.cpp:8: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
    8 | #pragma region dalykai
      | 
nautilus.cpp:43: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   43 | #pragma endregion
      |
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Incorrect 2 ms 328 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Incorrect 2 ms 328 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Incorrect 2 ms 328 KB Output isn't correct
4 Halted 0 ms 0 KB -