Submission #444778

# Submission time Handle Problem Language Result Execution time Memory
444778 2021-07-15T08:24:30 Z prvocislo Nautilus (BOI19_nautilus) C++17
100 / 100
146 ms 776 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int maxn = 505;
int r, c, m;
vector<bitset<maxn> > v(maxn); // povodne pole
void w(vector<bitset<maxn> > &b)
{
    for (int i = 0; i < r; i++) b[i] >>= 1;
}
void e(vector<bitset<maxn> > &b)
{
    for (int i = 0; i < r; i++) b[i] <<= 1;
}
void n(vector<bitset<maxn> > &b)
{
    for (int i = 0; i < r; i++) b[i] = b[i+1];
}
void s(vector<bitset<maxn> > &b)
{
    for (int i = r-1; i > 0; i--) b[i] = b[i-1];
    b[0] = 0;
}
void fix(vector<bitset<maxn> > &b)
{
    for (int i = 0; i < r; i++) b[i] &= v[i];
}
void print(vector<bitset<maxn> > &b)
{
    cout << "\n=============\n";
    for (int i = 0; i < r; i++)
    {
       for (int j = 0; j < c; j++) cout << b[i][j];
       cout << "\n";
    }
    cout << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> m;
    for (int i = 0; i < r; i++)
    {
        string vi; cin >> vi;
        for (int j = 0; j < c; j++) 
            if (vi[j] == '.') v[i][j] = 1;
    }
    //print(v);
    string st; cin >> st;
    vector<bitset<maxn> > b = v;
    //print(b);
    for (char ch : st)
    {
        if (ch == 'N') n(b);
        if (ch == 'E') e(b);
        if (ch == 'S') s(b);
        if (ch == 'W') w(b);
        if (ch == '?') // mozeme urobit lubovolny zo styroch krokov
        {
            vector<bitset<maxn> > nw[4];
            for (int j = 0; j < 4; j++) nw[j] = b;
            n(nw[0]), e(nw[1]), s(nw[2]), w(nw[3]);
            for (int j = 0; j < r; j++) for (int k = 1; k < 4; k++) nw[0][j] |= nw[k][j];
            b = nw[0];
        }
        fix(b);
        //print(b);
    }
    //print(b);
    int ans = 0;
    for (int i = 0; i < r; i++)
        ans += b[i].count();
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 2 ms 480 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 2 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 2 ms 480 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 2 ms 480 KB Output is correct
22 Correct 66 ms 736 KB Output is correct
23 Correct 64 ms 716 KB Output is correct
24 Correct 63 ms 716 KB Output is correct
25 Correct 64 ms 716 KB Output is correct
26 Correct 59 ms 740 KB Output is correct
27 Correct 116 ms 776 KB Output is correct
28 Correct 109 ms 760 KB Output is correct
29 Correct 116 ms 764 KB Output is correct
30 Correct 110 ms 716 KB Output is correct
31 Correct 108 ms 716 KB Output is correct
32 Correct 145 ms 764 KB Output is correct
33 Correct 142 ms 776 KB Output is correct
34 Correct 146 ms 760 KB Output is correct
35 Correct 142 ms 716 KB Output is correct
36 Correct 145 ms 716 KB Output is correct