Submission #419854

# Submission time Handle Problem Language Result Execution time Memory
419854 2021-06-07T14:14:24 Z nicolaalexandra Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#define DIM 5010
using namespace std;

char v[DIM],s[DIM];
int n,m,k,i,j;

bitset <DIM> a[2][DIM],mask[DIM];

int main (){

    ifstream cin ("date.in");
    ofstream cout ("date.out");

    cin>>n>>m>>k;

    for (i=1;i<=n;i++){
        cin>>s+1;
        for (j=1;j<=m;j++)
            if (s[j] == '.')
                mask[i][j] = a[0][i][j] = 1;
    }

    cin>>v+1;

    int t = 1;
    for (int pas=1;pas<=k;pas++){

        for (i=1;i<=n;i++)
            a[t][i].reset();


        for (i=1;i<=n;i++){
            if (v[pas] == 'N'){

                if (i < n)
                    a[t][i] = a[1-t][i+1] & mask[i];

            } else {
                if (v[pas] == 'S'){
                    if (i > 1)
                        a[t][i] = a[1-t][i-1] & mask[i];
                } else {
                    if (v[pas] == 'E'){

                        a[t][i] = (a[1-t][i] >> 1) & mask[i];

                    } else {
                        if (v[pas] == 'V'){

                            a[t][i] = (a[1-t][i] << 1) & mask[i];

                        } else { /// ?

                            if (i < n)
                                a[t][i] = a[1-t][i+1] & mask[i];
                            if (i > 1)
                                a[t][i] |= a[1-t][i-1] & mask[i];

                            a[t][i] |= (a[1-t][i] >> 1) & mask[i];
                            a[t][i] |= (a[1-t][i] << 1) & mask[i];
                        }}}}}

        t = 1-t;

    }

    int sol = 0;
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            sol += a[1-t][i][j];

    cout<<sol;


    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:18:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |         cin>>s+1;
      |              ~^~
nautilus.cpp:24:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |     cin>>v+1;
      |          ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -