답안 #729800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729800 2023-04-24T15:19:37 Z vjudge1 Nautilus (BOI19_nautilus) C++14
0 / 100
3 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

int di[4]={1,-1,0,0};
int dj[4]={0,0,-1,1};

int main()
{
    ios_base::sync_with_stdio(false);
    int r,c,mx;
    string m;
    cin>>r>>c>>mx;
    char mat[r][c];
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cin>>mat[i][j];
        }
    }
    cin>>m;
    int ans=0;
    queue<int>Q;
    bool vis[r][c];
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(mat[i][j]=='.')///"";
            {
                memset(vis,0,sizeof vis);
                Q.push(i);
                Q.push(j);
                Q.push(0);
                vis[i][j]=1;
                while(!Q.empty())
                {
                    int ti=Q.front();Q.pop();
                    int tj=Q.front();Q.pop();
                    int k=Q.front();Q.pop();
                    if(k==m.size())
                    {
                        ans++;
                    }
                    else
                    {
                        if(m[k]=='?')
                        {
                            for(int idx=0;idx<4;idx++)
                            {
                                int ci=ti+di[idx];
                                int cj=tj+dj[idx];
                                if(ci<0||cj<0||ci>=r||cj>=c)continue;
                                if(mat[ci][cj]=='#')continue;
                                if(vis[ci][cj])continue;
                                Q.push(ci);
                                Q.push(cj);
                                Q.push(k+1);
                                vis[ci][cj]=true;
                            }
                        }
                        else
                        {
                            int ci=ti;
                            int cj=tj;
                            if(m[k]=='N')
                            {
                                ci--;
                            }
                            else if(m[k]=='S')
                            {
                                ci++;
                            }
                            else if(m[k]=='W')
                            {
                                cj--;
                            }
                            else
                            {
                                cj++;
                            }
                            if(ci<0||cj<0||ci>=r||cj>=c)continue;
                            if(mat[ci][cj]=='#')continue;
                            if(vis[ci][cj])continue;
                            Q.push(ci);
                            Q.push(cj);
                            Q.push(k+1);
                            vis[ci][cj]=true;
                        }
                    }
                }
                while(!Q.empty())
                {
                    Q.pop();
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                     if(k==m.size())
      |                        ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -