답안 #729798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729798 2023-04-24T15:15:12 Z vjudge1 Nautilus (BOI19_nautilus) C++14
29 / 100
1000 ms 231124 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;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(mat[i][j]=='.')///"";
            {
                Q.push(i);
                Q.push(j);
                Q.push(0);
                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;
                                Q.push(ci);
                                Q.push(cj);
                                Q.push(k+1);
                            }
                        }
                        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;
                            Q.push(ci);
                            Q.push(cj);
                            Q.push(k+1);
                        }
                    }
                }
                while(!Q.empty())
                {
                    Q.pop();
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:39:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                     if(k==m.size())
      |                        ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Execution timed out 1082 ms 231124 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Execution timed out 1082 ms 231124 KB Time limit exceeded
8 Halted 0 ms 0 KB -