Submission #123010

# Submission time Handle Problem Language Result Execution time Memory
123010 2019-06-30T01:44:56 Z model_code Nautilus (BOI19_nautilus) C++17
0 / 100
4 ms 376 KB
#include <iostream>
#include <bitset>
#include <string>

using namespace std;

const int maxn = 505;

bitset<maxn> grid [maxn];
bitset<maxn> possibles [2][maxn];

int main () {
  int height, width, message;
  cin >> height >> width >> message;

  for (int i = 1; i <= height; i++) {
    for (int j = 1; j <= width; j++) {
      char x;
      cin >> x;

      if (x == '.') {
        grid[i][j] = 1;
      }
    }
  }

  for (int i = 1; i <= height; i++) {
    possibles[1][i] = grid[i];
  }

  string msg;
  cin >> msg;
  for (int i = 0; i < message; i++) {
    char c = msg[i];
    if (c == 'N') {
      for (int k = 1; k <= height; k++) {
        possibles[(i % 2)][k] = possibles[!(i % 2)][k + 1] & grid[k];
      }
    } else if (c == 'E') {
      for (int k = 1; k <= height; k++) {
        possibles[(i % 2)][k] = (possibles[!(i % 2)][k] << 1) & grid[k];
      }
    } else if (c == 'S') {
      for (int k = 1; k <= height; k++) {
        possibles[(i % 2)][k] = possibles[!(i % 2)][k - 1] & grid[k];
      }
    } else if (c == 'W') {
      for (int k = 1; k <= height; k++) {
        possibles[(i % 2)][k] = (possibles[!(i % 2)][k] >> 1) & grid[k];
      }
    } else {
      for (int k = 1; k <= height; k++) {
        possibles[(i % 2)][k]= ((possibles[!(i % 2)][k] << 1) | (possibles[!(i % 2)][k] >> 1)
                            | possibles[!(i % 2)][k - 1] | possibles[!(i % 2)][k + 1]) & grid[k];
      }
    }

    /*
    for (int k = 1; k <= height; k++) {
      cout << possibles[(i % 2)][k].to_string() << endl;
    }
    cout << endl;
    */
    int ans = 0;
    for (int k = 1; k <= height; k++) {
      ans += possibles[(i) % 2][k].count();
    }
    cout << ans << endl;

  }

  int ans = 0;
  for (int i = 1; i <= height; i++) {
    ans += possibles[(message - 1) % 2][i].count();
  }
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -