Submission #900629

# Submission time Handle Problem Language Result Execution time Memory
900629 2024-01-08T17:26:25 Z gortomi Nautilus (BOI19_nautilus) C++17
100 / 100
165 ms 752 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r, c, m;
    cin >> r >> c >> m;
    vector<bitset<502> > isl(r + 2);

    for(int i = 0; i <= r + 1; i++)
    {
        for(int j = 0; j <= c + 1; j++)
        {
            if(i == 0 || i == r + 1 || j == 0 || j == c + 1)
            {
                isl[i][j] = 1;
                continue;
            }
            char c;
            cin >> c;
            isl[i][j] = (c == '#');
        }
    }
    vector<bitset<502> > bad = isl, bad2(r + 2);
    string s;
    cin >> s;
    for(auto z : s)
    {
        for(int i = 0; i <= r + 1; i++)
        {
            bad2[i] = isl[i];
            if(i == 0 || i == r + 1) continue;
            if(z == 'N')
            {
                bad2[i] |= bad[i + 1];
            }
            else if(z == 'S')
            {
                bad2[i] |= bad[i - 1];
            }
            else if(z == 'E')
            {
                bad2[i] |= (bad[i] << 1);
            }
            else if(z == 'W')
            {
                bad2[i] |= (bad[i] >> 1);
            }
            else if(z == '?')
            {
                bad2[i] = bad[i - 1] & bad[i + 1] & (bad[i] << 1) & (bad[i] >> 1);
                bad2[i] |= isl[i];
            }
            //for(int j = 1; j <= c; j++) cout << 1 - bad2[i][j] << " ";
            //cout << "\n";
        }
        //cout << "\n";
        bad = bad2;
    }
    int ans = 0;
    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {

            ans += 1 - bad[i][j];
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 78 ms 348 KB Output is correct
23 Correct 77 ms 352 KB Output is correct
24 Correct 75 ms 344 KB Output is correct
25 Correct 77 ms 752 KB Output is correct
26 Correct 73 ms 348 KB Output is correct
27 Correct 125 ms 344 KB Output is correct
28 Correct 127 ms 536 KB Output is correct
29 Correct 130 ms 592 KB Output is correct
30 Correct 127 ms 348 KB Output is correct
31 Correct 123 ms 344 KB Output is correct
32 Correct 165 ms 592 KB Output is correct
33 Correct 165 ms 348 KB Output is correct
34 Correct 164 ms 344 KB Output is correct
35 Correct 163 ms 348 KB Output is correct
36 Correct 165 ms 596 KB Output is correct