Submission #723034

# Submission time Handle Problem Language Result Execution time Memory
723034 2023-04-13T07:44:22 Z adrilen Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 13432 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
constexpr int maxm = 5e3 + 1, maxa = 5e2 + 2;

bitset <maxa> ma[maxm][maxa];

vector<pii> dir[] = { vector<pii>{pii( -1, 0 )}, vector<pii>{pii( 1, 0 )}, vector<pii>{pii( 0, -1 )},
                    vector<pii>{pii( 0, 1 )}, vector<pii>{pii( -1, 0 ), pii(1, 0), pii(0, -1), pii(0, 1)}};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int r, c, m;
    cin >> r >> c >> m;

    string s;
    for (int y = 1; y <= r; y++)
    {
        cin >> s;
        for (int x = 1; x <= c; x++)
        {
            if (s[x - 1] == '.') ma[0][x][y] = true;
        }
    }
    int output;

    cin >> s;
    int typ;
    for (int i = 1; i <= m; i++)
    {
        if (s[i - 1]=='W') typ = 0;
        else if (s[i - 1]=='E') typ = 1;
        else if (s[i - 1]=='N') typ = 2; 
        else if (s[i - 1] == 'S') typ = 3;
        else typ = 4;

        // cout << dir[typ][0].first << " " << dir[typ][0].second << " " << dir[typ].size() <<"\n";

        for (int y = 1; y <= r; y++)
        {
            for (int x = 1; x <= c; x++)
            {
                for (pii &p : dir[typ])
                {
                    if (ma[0][x + p.first][y + p.second] && ma[i - 1][x][y]) 
                        ma[i][x + p.first][y + p.second] = true;
                }
            }
        }
    }
    // for (int i = 0; i <= m; i++)
    // {
    //     cout << i <<"\n";
    //     for (int y = 1; y <= r; y ++) 
    //     {
    //         for (int x = 1; x <= c; x++) cout << ma[i][x][y];
    //         cout << "\n";
    //     }
    //     cout <<"\n";
    // }

    output = 0;
    for (int x = 1; x <= c; x++)
    {
        output += ma[m][x].count();
    }
    cout << output << "\n";

    // cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 8 ms 1180 KB Output is correct
3 Correct 10 ms 1148 KB Output is correct
4 Correct 11 ms 852 KB Output is correct
5 Correct 6 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 8 ms 1180 KB Output is correct
3 Correct 10 ms 1148 KB Output is correct
4 Correct 11 ms 852 KB Output is correct
5 Correct 6 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 10 ms 1232 KB Output is correct
8 Correct 15 ms 1364 KB Output is correct
9 Correct 16 ms 1236 KB Output is correct
10 Correct 11 ms 904 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 19 ms 1316 KB Output is correct
13 Correct 18 ms 1332 KB Output is correct
14 Correct 30 ms 1224 KB Output is correct
15 Correct 15 ms 1236 KB Output is correct
16 Correct 7 ms 724 KB Output is correct
17 Correct 21 ms 1288 KB Output is correct
18 Correct 24 ms 1236 KB Output is correct
19 Correct 25 ms 1228 KB Output is correct
20 Correct 24 ms 1236 KB Output is correct
21 Correct 12 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 8 ms 1180 KB Output is correct
3 Correct 10 ms 1148 KB Output is correct
4 Correct 11 ms 852 KB Output is correct
5 Correct 6 ms 724 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 10 ms 1232 KB Output is correct
8 Correct 15 ms 1364 KB Output is correct
9 Correct 16 ms 1236 KB Output is correct
10 Correct 11 ms 904 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 19 ms 1316 KB Output is correct
13 Correct 18 ms 1332 KB Output is correct
14 Correct 30 ms 1224 KB Output is correct
15 Correct 15 ms 1236 KB Output is correct
16 Correct 7 ms 724 KB Output is correct
17 Correct 21 ms 1288 KB Output is correct
18 Correct 24 ms 1236 KB Output is correct
19 Correct 25 ms 1228 KB Output is correct
20 Correct 24 ms 1236 KB Output is correct
21 Correct 12 ms 724 KB Output is correct
22 Execution timed out 1051 ms 13432 KB Time limit exceeded
23 Halted 0 ms 0 KB -