제출 #1187913

#제출 시각아이디문제언어결과실행 시간메모리
1187913CrabCNHNautilus (BOI19_nautilus)C++20
100 / 100
141 ms1052 KiB
#include <bits/stdc++.h>

#define task   "BriantheCrab"

#define int    long long
#define pii    pair <int, int>
#define fi     first
#define se     second
#define szf    sizeof
#define sz(s)  (int)((s).size())

using namespace std;

template <class T> void mini (T &t, T f) {if (t > f) t = f;}
template <class T> void maxi (T &t, T f) {if (t < f) t = f;}

const int maxN = 500 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;

int n, m, x;
char a[maxN][maxN];
string s;
bitset <maxN * maxN> dp, ok;

int mask (int i, int j) {
    return i * (m + 1) + j;
}

void solve () {
    cin >> n >> m >> x;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < m; j ++) {
            cin >> a[i][j];
            if (a[i][j] == '.') {
                ok[mask (i, j)] = 1;
            }
        }
    }    
    cin >> s;
    s = ' ' + s;
    dp = ok;
    for (auto c : s) {
        if (c == '?') {
            dp = (dp << 1) | (dp >> 1) | (dp << (m + 1)) | (dp >> (m + 1));
        }
        if (c == 'E') {
            dp <<= 1;
        }
        if (c == 'W') {
            dp >>= 1;
        }
        if (c == 'S') {
            dp <<= (m + 1); 
        }
        if (c == 'N') {
            dp >>= (m + 1);
        }
        dp &= ok;
    }
    cout << dp.count ();
}

signed main () {
    cin.tie (nullptr) -> sync_with_stdio (false);
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int t = 1;
    //cin >> t;
    while (t --) {
        solve ();
    } 
    return 0;
}
// thfdgb

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

nautilus.cpp: In function 'int main()':
nautilus.cpp:67:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:68:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...