제출 #314126

#제출 시각아이디문제언어결과실행 시간메모리
314126kimbj0709Nautilus (BOI19_nautilus)C++14
100 / 100
199 ms512 KiB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  bitset<maxn> dp[maxn][2];
  bitset<maxn> arr[maxn];
  int n,m,len;
  cin >> n >> m >> len;
  string input;
  char inp;
  for(int i=1;i<=n;i++){
    cin >> input;
    for(int j=1;j<=m;j++){
      if(input.at(j-1)=='.'){
        arr[i][j] = 1;
      }
    }
    dp[i][0] = arr[i];
  }
  cin >> input;
  for(int i=0;i<len;i++){
    for(int a=1;a<=n;a++){
      if(input.at(i)=='N'){
        dp[a][(i+1)&1] = dp[a+1][i&1];
      }
      if(input.at(i)=='S'){
        dp[a][(i+1)&1] = dp[a-1][i&1];
      }
      if(input.at(i)=='W'){
        dp[a][(i+1)&1] = dp[a][i&1] >> 1;
      }
      if(input.at(i)=='E'){
        dp[a][(i+1)&1] = dp[a][i&1] << 1;
      }
      if(input.at(i)=='?'){
        dp[a][(i+1)&1] = (dp[a][i&1] << 1)|(dp[a][i&1] >> 1)|(dp[a-1][i&1])|(dp[a+1][i&1]);
      }
      dp[a][(i+1)&1] &= arr[a];
    }
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    ans += dp[i][(input.length())&1].count();
  }
  cout << ans;
}

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp: In function 'int32_t main()':
nautilus.cpp:12:8: warning: unused variable 'inp' [-Wunused-variable]
   12 |   char inp;
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...