Submission #540877

# Submission time Handle Problem Language Result Execution time Memory
540877 2022-03-21T22:09:54 Z Olympia Nautilus (BOI19_nautilus) C++17
100 / 100
248 ms 1040 KB
#include <cmath>
#include <iostream>
#include <set>
#include <climits>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <type_traits>
#include <bit>
#include <bitset>
#include <string>
#include <queue>

#define ll long long

#include <map>

using namespace std;
vector<string> vec;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int R, C, M;
    cin >> R >> C >> M;
    vec.resize(R);
    for (int i = 0; i < R; i++) {
        cin >> vec[i];
        assert(vec[i].size() == C);
    }
    string s;
    cin >> s;
    vector<bitset<1000>> orig(R);
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            if (vec[i][j] == '.') {
                orig[i].set(j + 500);
            }
        }
    }
    vector<bitset<1000>> pos = orig;
    map<char, pair<int, int>> myMap;
    myMap['W'] = {0, -1};
    myMap['E'] = {0, 1};
    myMap['S'] = {1, 0};
    myMap['N'] = {-1, 0};
    for (int i = 0; i < s.length(); i++) {
        vector<bitset<1000>> dum(R);
        if (s[i] == '?' || s[i] == 'W') {
            for (int j = 0; j < R; j++) {
                dum[j] |= (pos[j] >> 1);
            }
        }
        if (s[i] == '?' || s[i] == 'E') {
            for (int j = 0; j < R; j++) {
                dum[j] |= (pos[j] << 1);
            }
        }
        if (s[i] == '?' || s[i] == 'N') {
            for (int j = 0; j < R - 1; j++) {
                dum[j] |= pos[j + 1];
            }
        }
        if (s[i] == '?' || s[i] == 'S') {
            for (int j = 1; j < R; j++) {
                dum[j] |= pos[j - 1];
            }
        }
        for (int j = 0; j < R; j++) {
            pos[j] = dum[j] & orig[j];
        }
    }
    int ans = 0;
    for (int i = 0; i < R; i++) {
        ans += pos[i].count();
    }
    cout << ans;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from nautilus.cpp:7:
nautilus.cpp: In function 'int main()':
nautilus.cpp:33:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         assert(vec[i].size() == C);
      |                ~~~~~~~~~~~~~~^~~~
nautilus.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 144 ms 844 KB Output is correct
23 Correct 142 ms 1020 KB Output is correct
24 Correct 160 ms 980 KB Output is correct
25 Correct 139 ms 980 KB Output is correct
26 Correct 138 ms 980 KB Output is correct
27 Correct 199 ms 1024 KB Output is correct
28 Correct 215 ms 1040 KB Output is correct
29 Correct 193 ms 1028 KB Output is correct
30 Correct 204 ms 980 KB Output is correct
31 Correct 202 ms 1024 KB Output is correct
32 Correct 236 ms 980 KB Output is correct
33 Correct 234 ms 980 KB Output is correct
34 Correct 248 ms 980 KB Output is correct
35 Correct 229 ms 1028 KB Output is correct
36 Correct 229 ms 1028 KB Output is correct