Submission #515636

# Submission time Handle Problem Language Result Execution time Memory
515636 2022-01-19T11:32:24 Z nhphucqt Nautilus (BOI19_nautilus) C++17
0 / 100
3 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

const int D[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
const int NROW = 507;
const int NCOL = 507;
const int N = 5007;
int numRow, numCol, n;
bitset<NCOL> ans[NROW], tmp[NROW], islands[NROW];
int res;

void process(char c) {
    if (c == 'W') {
        for (int i = 1; i <= numRow; ++i) {
            ans[i] = (ans[i]>>1) & islands[i];
        }
    }
    else if (c == 'E') {
        for (int i = 1; i <= numRow; ++i) {
            ans[i] = (ans[i]<<1) & islands[i];
        }
    }
    else if (c == 'N') {
        for (int i = 1; i <= numRow; ++i) {
            ans[i] = ans[i+1] & islands[i];
        }
    }
    else if (c == 'S') {
        for (int i = numRow; i >= 1; --i) {
            ans[i] = ans[i-1] & islands[i];
        }
    }
    else {
        for (int i = 1; i <= numRow; ++i) {
            tmp[i] = ((ans[i]>>1) | (ans[i]<<1) | ans[i-1] | ans[i+1]) & islands[i];
        }
        for (int i = 1; i <= numRow; ++i) {
            ans[i] = tmp[i];
        }
    }

    // for (int i = 1; i <= numRow; ++i, cerr << '\n')
    // for (int j = 1; j <= numCol; ++j) cerr << ans[i][j];
    // cerr << '\n';
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    freopen("NAUTILUS.inp", "r", stdin);
    freopen("NAUTILUS.out", "w", stdout);

    cin >> numRow >> numCol >> n;
    for (int i = 1; i <= numRow; ++i)
    for (int j = 1; j <= numCol; ++j) {
        char c; cin >> c;
        islands[i][j] = c == '.';
        ans[i][j] = c == '.';
    }
    // for (int i = 1; i <= numRow; ++i, cerr << '\n')
    // for (int j = 1; j <= numCol; ++j) cerr << ans[i][j];
    // cerr << '\n';
    for (int i = 1; i <= n; ++i) {
        char c; cin >> c;
        process(c);
    }
    for (int i = 1; i <= numRow; ++i)
    for (int j = 1; j <= numCol; ++j) {
        res += ans[i][j];
    }
    cout << res;
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:50:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     freopen("NAUTILUS.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:51:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     freopen("NAUTILUS.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -