CSES - Leirikisa 2 - Results
Submission details
Task:Nautilus
Sender:vgtcross
Submission time:2023-04-18 15:29:11 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED29
#2ACCEPTED37
#3ACCEPTED34
Test results
testverdicttimegroup
#1ACCEPTED0.00 s2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s2, 3details
#9ACCEPTED0.01 s2, 3details
#10ACCEPTED0.01 s2, 3details
#11ACCEPTED0.01 s2, 3details
#12ACCEPTED0.01 s2, 3details
#13ACCEPTED0.01 s2, 3details
#14ACCEPTED0.01 s2, 3details
#15ACCEPTED0.01 s2, 3details
#16ACCEPTED0.01 s2, 3details
#17ACCEPTED0.01 s2, 3details
#18ACCEPTED0.01 s2, 3details
#19ACCEPTED0.01 s2, 3details
#20ACCEPTED0.01 s2, 3details
#21ACCEPTED0.01 s2, 3details
#22ACCEPTED0.01 s2, 3details
#23ACCEPTED0.10 s3details
#24ACCEPTED0.10 s3details
#25ACCEPTED0.10 s3details
#26ACCEPTED0.10 s3details
#27ACCEPTED0.10 s3details
#28ACCEPTED0.16 s3details
#29ACCEPTED0.16 s3details
#30ACCEPTED0.16 s3details
#31ACCEPTED0.16 s3details
#32ACCEPTED0.16 s3details
#33ACCEPTED0.21 s3details
#34ACCEPTED0.21 s3details
#35ACCEPTED0.21 s3details
#36ACCEPTED0.22 s3details
#37ACCEPTED0.20 s3details

Code

#include <bits/stdc++.h>

#define fi first
#define se second

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, m, l;
void move(bitset<250000> &b, char c) {
    if (c == 'N') {
        b >>= m;
    } else if (c == 'E') {
        b <<= 1;
        for (int i = m; i <= n*m; i += m) {
            if (i >= 250000)
                break;
            b[i] = 0;
        }
    } else if (c == 'S') {
        b <<= m;
        for (int i = 0; i < m; ++i) {
            if (i + n*m >= 250000)
                break;
            b[i + n*m] = 0;
        }
    } else if (c == 'W') {
        b >>= 1;
        for (int i = m-1; i < n*m; i += m)
            b[i] = 0;
    }
}

void solve() {
    bitset<250000> b(0);
    cin >> n >> m >> l;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            b[m*i + j] = c == '.';
        }
    }
    
    string s;
    cin >> s;
    bitset<250000> cur = b;
    bitset<250000> m1, m2, m3;
    
    for (char c: s) {
        if (c == '?') {
            m1 = m2 = m3 = cur;
            move(m1, 'N');
            move(m2, 'E');
            move(m3, 'S');
            move(cur, 'W');
            cur = (cur | m1 | m2 | m3) & b;
        } else {
            move(cur, c);
            cur &= b;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < n*m; ++i) {
        ans += cur[i];
    }
    
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    solve();
    
    return 0;
}

Test details

Test 1

Group: 2, 3

Verdict: ACCEPTED

input
5 9 7
...##....
..#.##..#
..#....##
.##...#..
...

correct output
22

user output
22

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
.................................

correct output
8272

user output
8272

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
.#...#.#..#.....#.........#......

correct output
5

user output
5

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
.#...##...#...##....##.#.##..#...

correct output
1

user output
1

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
..#.#.#..###.#.#.##..########....

correct output
1

user output
1

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
.#.#.###########..#.###.######...

correct output
1

user output
1

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 100 100
##############################...

correct output
1

user output
1

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.................................

correct output
9503

user output
9503

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
#..#.##..#....##...#.##.##..#....

correct output
495

user output
495

Test 10

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
#.#...######.#####.#.##...#.##...

correct output
51

user output
51

Test 11

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.#.#.###########..#.###.######...

correct output
34

user output
34

Test 12

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
##############################...

correct output
19

user output
19

Test 13

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.................................

correct output
9801

user output
9801

Test 14

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
..............#..................

correct output
7479

user output
7479

Test 15

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
#.#.........###.#..#.#..####.#...

correct output
5328

user output
5328

Test 16

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.#.#.###########..#.###.######...

correct output
127

user output
127

Test 17

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
##############################...

correct output
19

user output
19

Test 18

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.................................

correct output
10000

user output
10000

Test 19

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
..............#..................

correct output
8047

user output
8047

Test 20

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
#.#...######.#####.#.##...#.##...

correct output
3500

user output
3500

Test 21

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
.#.#.###########..#.###.######...

correct output
1228

user output
1228

Test 22

Group: 2, 3

Verdict: ACCEPTED

input
100 100 100
##############################...

correct output
43

user output
43

Test 23

Group: 3

Verdict: ACCEPTED

input
500 500 5000
.................................

correct output
249493

user output
249493

Test 24

Group: 3

Verdict: ACCEPTED

input
500 500 5000
#..#.##..#....##...#.##.##..#....

correct output
222

user output
222

Test 25

Group: 3

Verdict: ACCEPTED

input
500 500 5000
.#####....####..###...####.#.#...

correct output
1268

user output
1268

Test 26

Group: 3

Verdict: ACCEPTED

input
500 500 5000
#.#####.##..#####.####..######...

correct output
805

user output
805

Test 27

Group: 3

Verdict: ACCEPTED

input
500 500 5000
##############################...

correct output
349

user output
349

Test 28

Group: 3

Verdict: ACCEPTED

input
500 500 5000
.................................

correct output
249999

user output
249999

Test 29

Group: 3

Verdict: ACCEPTED

input
500 500 5000
..............#..................

correct output
197917

user output
197917

Test 30

Group: 3

Verdict: ACCEPTED

input
500 500 5000
#.#.........###.#..#.#..####.#...

correct output
79550

user output
79550

Test 31

Group: 3

Verdict: ACCEPTED

input
500 500 5000
#.#####.##..#####.####..######...

correct output
1221

user output
1221

Test 32

Group: 3

Verdict: ACCEPTED

input
500 500 5000
##############################...

correct output
1414

user output
1414

Test 33

Group: 3

Verdict: ACCEPTED

input
500 500 5000
.................................

correct output
250000

user output
250000

Test 34

Group: 3

Verdict: ACCEPTED

input
500 500 5000
..............#..................

correct output
199752

user output
199752

Test 35

Group: 3

Verdict: ACCEPTED

input
500 500 5000
.#####....####..###...####.#.#...

correct output
87691

user output
87691

Test 36

Group: 3

Verdict: ACCEPTED

input
500 500 5000
#.#####.##..#####.####..######...

correct output
30998

user output
30998

Test 37

Group: 3

Verdict: ACCEPTED

input
500 500 5000
##############################...

correct output
1440

user output
1440