Submission #450417

# Submission time Handle Problem Language Result Execution time Memory
450417 2021-08-02T20:07:46 Z Ozy Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 6492 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

lli f,c,n,d;
lli arr[502][502], dir[8] = {-1,0,1,0,0,1,0,-1};
vector<vector<lli> > pas,nuevo;
char x;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> f >> c >> n;

    pas.resize(f+2);
    nuevo.resize(f+2);
    rep(i,0,f+1) {pas[i].resize(c+2); nuevo[i].resize(c+2);}

    rep(i,1,f) {
        rep(j,1,c) {
            cin >> x;
            if (x == '.') {
                arr[i][j] = 1;
                pas[i][j] = 1;
            }
            else arr[i][j] = 0;
        }
    }

    rep(act,1,n) {
        cin >> x;
        if (x == 'N') d = 0;
        else if (x == 'E') d = 1;
        else if (x == 'S') d = 2;
        else if (x == 'W') d = 3;
        else d = -1;

        rep(i,1,f) {
            rep(j,1,c) {

                if (arr[i][j] == 0) continue;
                if (pas[i][j] != act) continue;
                rep(k,0,3) {
                    if (d != -1 && d != k) continue;
                    nuevo[i + dir[k]][j + dir[k+4]] = act+1;
                }

            }
        }

        swap(pas,nuevo);
    }

    lli sum = 0;
    rep(i,1,f) {
        rep(j,1,c) {
            if (arr[i][j] == 0) continue;
            if (pas[i][j] == n+1) sum++;
        }
    }
    cout << sum;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 896 KB Output is correct
2 Correct 5 ms 844 KB Output is correct
3 Correct 5 ms 844 KB Output is correct
4 Correct 4 ms 844 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 2 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 896 KB Output is correct
2 Correct 5 ms 844 KB Output is correct
3 Correct 5 ms 844 KB Output is correct
4 Correct 4 ms 844 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 2 ms 844 KB Output is correct
7 Correct 14 ms 844 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 6 ms 844 KB Output is correct
10 Correct 4 ms 844 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 21 ms 844 KB Output is correct
13 Correct 19 ms 892 KB Output is correct
14 Correct 16 ms 884 KB Output is correct
15 Correct 4 ms 844 KB Output is correct
16 Correct 2 ms 844 KB Output is correct
17 Correct 28 ms 900 KB Output is correct
18 Correct 24 ms 896 KB Output is correct
19 Correct 14 ms 844 KB Output is correct
20 Correct 7 ms 844 KB Output is correct
21 Correct 2 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 896 KB Output is correct
2 Correct 5 ms 844 KB Output is correct
3 Correct 5 ms 844 KB Output is correct
4 Correct 4 ms 844 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 2 ms 844 KB Output is correct
7 Correct 14 ms 844 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 6 ms 844 KB Output is correct
10 Correct 4 ms 844 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 21 ms 844 KB Output is correct
13 Correct 19 ms 892 KB Output is correct
14 Correct 16 ms 884 KB Output is correct
15 Correct 4 ms 844 KB Output is correct
16 Correct 2 ms 844 KB Output is correct
17 Correct 28 ms 900 KB Output is correct
18 Correct 24 ms 896 KB Output is correct
19 Correct 14 ms 844 KB Output is correct
20 Correct 7 ms 844 KB Output is correct
21 Correct 2 ms 844 KB Output is correct
22 Execution timed out 1093 ms 6492 KB Time limit exceeded
23 Halted 0 ms 0 KB -