답안 #552075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552075 2022-04-22T11:36:41 Z ollel Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 340 KB
using namespace std;
#include <bits/stdc++.h>

#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int rows, cols, m;

string commands;

const int maxrows = 501;
vector<bitset<maxrows>> blocked(maxrows);
vector<bitset<maxrows>> yes(maxrows), nyes(maxrows);

int main() {
  cin >> rows >> cols >> m;

  blocked.resize(rows);
  rep(r,0,rows) blocked[r].reset();

    rep(r,0,rows) {
    string s; cin >> s;
    rep(c,0,cols) {
      if (s[c] == '.') blocked[r].set(c);
    }
  }
  cin >> commands;

  rep(r,0,rows) yes[r].set();


  rep(i,0,m) {
    rep(r,0,rows) nyes[r].reset();
    if (commands[i] == 'W') {
      rep(r,0,rows) nyes[r] = (yes[r] >> 1) & blocked[r];
    }
    if (commands[i] == 'E') {
      rep(r,0,rows) nyes[r] = (yes[r] << 1) & blocked[r];
    }
    if (commands[i] == 'S') {
      rep(r,0,rows - 1) nyes[r] = yes[r + 1] & blocked[r];
    }
    if (commands[i] == 'N') {
      rep(r,1,rows) nyes[r] = yes[r - 1] & blocked[r];
    }
    if (commands[i] == '?') {
      nyes[0] = (yes[1] | (yes[0] >> 1) | (yes[0] << 1)) & blocked[0];
      rep(r,1,rows - 1) {
        nyes[r] = (yes[r + 1] | yes[r - 1] | (yes[r] >> 1) | (yes[r] << 1)) & blocked[r];
      }
      nyes[rows - 1] = (yes[rows - 2] | (yes[rows - 1] >> 1) | (yes[rows - 1] << 1)) & blocked[rows - 1];
    }

    rep(r,0,rows) yes[r] = nyes[r];
  }
  int ans = 0;
  rep(r,0,rows) rep(c,0,cols) if (yes[r].test(c)) ans++;
  cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -