답안 #1021789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021789 2024-07-13T05:22:41 Z m5588ohammed Nautilus (BOI19_nautilus) C++14
29 / 100
1000 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int n,m,p,cnt;
char arr[101][101];
int vis[101][101],dp[101][101][101];
string s;
void solve(int i,int j,int k){
    if(i>=n||j>=m||i<0||j<0||arr[i][j]=='#') return;
    if(k==p){
        if(vis[i][j]!=1) cnt++;
        vis[i][j]=1;
        return;
    }
    if(s[k]=='N'||s[k]=='?') solve(i-1,j,k+1);
    if(s[k]=='S'||s[k]=='?') solve(i+1,j,k+1);
    if(s[k]=='E'||s[k]=='?') solve(i,j+1,k+1);
    if(s[k]=='W'||s[k]=='?') solve(i,j-1,k+1);
    return;
}
signed main()
{
    cin>>n>>m>>p;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>arr[i][j];
    }
    cin>>s;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) solve(i,j,0);
    }
    cout<<cnt<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Execution timed out 1063 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Execution timed out 1063 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -