Submission #540863

# Submission time Handle Problem Language Result Execution time Memory
540863 2022-03-21T21:12:43 Z Olympia Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 24280 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 <string>
#include <queue>
#define ll long long
#include <map>

using namespace std;
vector<string> vec;
int main() {
    //freopen("inp")
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set<pair<int,int>> pos;
    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;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            if (vec[i][j] == '.') {
                pos.insert({i, j});
            }
        }
    }
    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++) {
        set<pair<int,int>> valid;
        for (char c: {'W', 'N', 'S', 'E'}) {
            if (s[i] == c || s[i] == '?') {
                for (auto& p: pos) {
                    int dx = p.first + myMap[c].first;
                    int dy = p.second + myMap[c].second;
                    if (dx >= 0 && dy >= 0 && dx < R && dy < C && vec[dx][dy] == '.') {
                        valid.insert({dx, dy});
                    }
                }
            }
        }
        pos = valid;
    }
    cout << pos.size() << '\n';
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from nautilus.cpp:7:
nautilus.cpp: In function 'int main()':
nautilus.cpp:30:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |         assert(vec[i].size() == C);
      |                ~~~~~~~~~~~~~~^~~~
nautilus.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 123 ms 1236 KB Output is correct
2 Correct 9 ms 980 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 1236 KB Output is correct
2 Correct 9 ms 980 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 197 ms 1264 KB Output is correct
8 Correct 36 ms 816 KB Output is correct
9 Correct 9 ms 612 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 293 ms 1268 KB Output is correct
13 Correct 251 ms 1096 KB Output is correct
14 Correct 134 ms 852 KB Output is correct
15 Correct 8 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 351 ms 1224 KB Output is correct
18 Correct 298 ms 1096 KB Output is correct
19 Correct 99 ms 596 KB Output is correct
20 Correct 30 ms 468 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 1236 KB Output is correct
2 Correct 9 ms 980 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 197 ms 1264 KB Output is correct
8 Correct 36 ms 816 KB Output is correct
9 Correct 9 ms 612 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 293 ms 1268 KB Output is correct
13 Correct 251 ms 1096 KB Output is correct
14 Correct 134 ms 852 KB Output is correct
15 Correct 8 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 351 ms 1224 KB Output is correct
18 Correct 298 ms 1096 KB Output is correct
19 Correct 99 ms 596 KB Output is correct
20 Correct 30 ms 468 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Execution timed out 1070 ms 24280 KB Time limit exceeded
23 Halted 0 ms 0 KB -