Submission #655868

# Submission time Handle Problem Language Result Execution time Memory
655868 2022-11-05T20:18:08 Z 600Mihnea Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 1236 KB
bool home = 0;
bool verbose;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 500 + 7;
int n;
int m;
int sdim;
bool valid_place[N][N];
bool ok[N][N];
bool nok[N][N];
string s;

void print() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << ok[i][j];
    }
    cout << "\n";
  }
  cout << "##########################################\n";
}

int main() {
  if (home) {
    verbose = 1;
    freopen ("___input___.txt", "r", stdin);
  } else {
    verbose = 0;
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  }

  cin >> n >> m >> sdim;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) {
      char ch = s[j - 1];
      assert(ch == '.' || ch == '#');
      valid_place[i][j] = (ch == '.');
    }
  }
  cin >> s;
  assert((int) s.size() == sdim);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ok[i][j] = valid_place[i][j];
    }
  }
  for (int itp = 0; itp < sdim; itp++) {
    char ch = s[itp];
    assert(ch == 'N' || ch == 'E' || ch == 'S' || ch == 'W' || ch == '?');
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        nok[i][j] = 0;
      }
    }
    if (ch == 'N' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          nok[i][j] |= ok[i + 1][j];
        }
      }
    }
    if (ch == 'S' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          nok[i][j] |= ok[i - 1][j];
        }
      }
    }
    if (ch == 'E' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          nok[i][j] |= ok[i][j - 1];
        }
      }
    }

    if (ch == 'W' || ch == '?') {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          nok[i][j] |= ok[i][j + 1];
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        ok[i][j] = nok[i][j] & valid_place[i][j];
      }
    }

    int sol = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        sol += ok[i][j];
      }
    }
  }
  int sol = 0, sol2 = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sol += ok[i][j];
     // cout << (is_ok(i, j, 0) ^ ok[i][j]) << " ";
    }
   // cout << "\n";
  }
  cout << sol << "\n";
  return 0;
}


/**

**/

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:105:16: warning: unused variable 'sol2' [-Wunused-variable]
  105 |   int sol = 0, sol2 = 0;
      |                ^~~~
nautilus.cpp:32:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen ("___input___.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 444 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 444 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 4 ms 468 KB Output is correct
13 Correct 3 ms 456 KB Output is correct
14 Correct 3 ms 460 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 4 ms 460 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 4 ms 468 KB Output is correct
21 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 444 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 4 ms 468 KB Output is correct
13 Correct 3 ms 456 KB Output is correct
14 Correct 3 ms 460 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 4 ms 460 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 4 ms 468 KB Output is correct
21 Correct 4 ms 460 KB Output is correct
22 Execution timed out 1079 ms 1236 KB Time limit exceeded
23 Halted 0 ms 0 KB -