Submission #200595

# Submission time Handle Problem Language Result Execution time Memory
200595 2020-02-07T13:40:25 Z johutha Nautilus (BOI19_nautilus) C++14
66 / 100
1000 ms 760 KB
#pragma GCC optimize("-Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
 
#define int int64_t
 
using namespace std;
 
signed main()
{
    int r, c, m;
    cin >> r >> c >> m;
 
    vector<vector<bool>> tab;
    vector<vector<bool>> st(r, vector<bool>(c));
    vector<vector<bool>> old(r, vector<bool>(c));
 
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            char ch;
            cin >> ch;
            st[i][j] = (ch == '.');
        }
    }
 
    tab = st;
 
    string seq;
    cin >> seq;
    // reverse(seq.begin(), seq.end());
    for (int i = 0; i < m; i++)
    {
        if (seq[i] == 'N') seq[i] = 'S';
        else if (seq[i] == 'S') seq[i] = 'N';
        else if (seq[i] == 'E') seq[i] = 'W';
        else if (seq[i] == 'W') seq[i] = 'E';
    }
 
    for (int t = 0; t < m; t++)
    {
        swap(old, tab);
        for (int i = 0; i < r; i++)
        {
            for (int j = 0; j < c; j++)
            {
                tab[i][j] = false;
                if (seq[t] == 'N' || seq[t] == '?') tab[i][j] = tab[i][j] || ((i - 1 >= 0) ? old[i - 1][j] : false);
                if (seq[t] == 'W' || seq[t] == '?') tab[i][j] = tab[i][j] || ((j - 1 >= 0) ? old[i][j - 1] : false);
                if (seq[t] == 'S' || seq[t] == '?') tab[i][j] = tab[i][j] || ((i + 1 < r) ? old[i + 1][j] : false);
                if (seq[t] == 'E' || seq[t] == '?') tab[i][j] = tab[i][j] || ((j + 1 < c) ? old[i][j + 1] : false);
                tab[i][j] = tab[i][j] && st[i][j];
            }
        }
        /*
        for (auto v : tab)
        {
            for (auto j : v)
            {
                cout << j << " ";
            }
            cout << "\n";
        }
        cout << "\n";
        */
    }
 
    int res = 0;
    for (auto v : tab) for (auto j : v) res += j;
    cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 12 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 12 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
7 Correct 12 ms 376 KB Output is correct
8 Correct 15 ms 376 KB Output is correct
9 Correct 13 ms 380 KB Output is correct
10 Correct 14 ms 376 KB Output is correct
11 Correct 14 ms 376 KB Output is correct
12 Correct 14 ms 376 KB Output is correct
13 Correct 17 ms 376 KB Output is correct
14 Correct 22 ms 376 KB Output is correct
15 Correct 14 ms 376 KB Output is correct
16 Correct 14 ms 380 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 17 ms 376 KB Output is correct
19 Correct 22 ms 380 KB Output is correct
20 Correct 17 ms 376 KB Output is correct
21 Correct 15 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 12 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
7 Correct 12 ms 376 KB Output is correct
8 Correct 15 ms 376 KB Output is correct
9 Correct 13 ms 380 KB Output is correct
10 Correct 14 ms 376 KB Output is correct
11 Correct 14 ms 376 KB Output is correct
12 Correct 14 ms 376 KB Output is correct
13 Correct 17 ms 376 KB Output is correct
14 Correct 22 ms 376 KB Output is correct
15 Correct 14 ms 376 KB Output is correct
16 Correct 14 ms 380 KB Output is correct
17 Correct 14 ms 376 KB Output is correct
18 Correct 17 ms 376 KB Output is correct
19 Correct 22 ms 380 KB Output is correct
20 Correct 17 ms 376 KB Output is correct
21 Correct 15 ms 376 KB Output is correct
22 Execution timed out 1084 ms 760 KB Time limit exceeded
23 Halted 0 ms 0 KB -