Submission #748391

#TimeUsernameProblemLanguageResultExecution timeMemory
748391vjudge1Nautilus (BOI19_nautilus)C++17
0 / 100
1 ms340 KiB
#include <iostream> #include <bitset> using namespace std; const int MAXN = 1005; const int MAXM = 1005; const int MAXLEN = 1005; const int MAXDIRS = 4; const int DR[MAXDIRS] = {-1, 0, 1, 0}; const int DC[MAXDIRS] = {0, 1, 0, -1}; int N, M; bitset<MAXN*MAXM> can_submarine_be_here, possible_locations; int main() { cin >> N >> M; for (int i = 0; i < N; ++i) { string line; cin >> line; for (int j = 0; j < M; ++j) { if (line[j] == '.') { can_submarine_be_here.set(i*M+j); possible_locations.set(i*M+j); } } } string signals; cin >> signals; for (int i = 0; i < signals.size(); ++i) { char d = signals[i]; if (d == 'N') d = 0; else if (d == 'E') d = 1; else if (d == 'S') d = 2; else if (d == 'W') d = 3; else continue; bitset<MAXN*MAXM> new_possible_locations; for (int j = possible_locations._Find_first(); j != possible_locations.size(); j = possible_locations._Find_next(j)) { int r = j / M; int c = j % M; int nr = r + DR[d]; int nc = c + DC[d]; if (nr >= 0 && nr < N && nc >= 0 && nc < M && can_submarine_be_here[nr*M+nc]) { new_possible_locations.set(nr*M+nc); } } possible_locations = new_possible_locations; } cout << possible_locations.count()-2; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < signals.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~
nautilus.cpp:42:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |             int nr = r + DR[d];
      |                             ^
nautilus.cpp:43:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |             int nc = c + DC[d];
      |                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...