답안 #419866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419866 2021-06-07T14:45:32 Z nicolaalexandra Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#define DIM 510
using namespace std;

char v[DIM*10],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] = 1;

        a[0][i] = mask[i];
    }

    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'){
                a[t][i] |= a[1-t][i+1];

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

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

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

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

                        } else { /// ?

                            a[t][i] |= a[1-t][i+1];
                            a[t][i] |= a[1-t][i-1];

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

            a[t][i] &= 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:26:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |     cin>>v+1;
      |          ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -