답안 #1021818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021818 2024-07-13T05:41:43 Z Almonther Nautilus (BOI19_nautilus) C++
29 / 100
1000 ms 348 KB
#include <bits/stdc++.h>

#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n,m,q;
string s[105];
string que;
ll vis[105][105];
void rec(ll i,ll j,ll idx){
    if(i>=n||i<0||j>=m||j<0) return;
    if(s[i][j]=='#') return;
    if(idx==q){
        vis[i][j]=1;
        return;
    }
    if(que[idx]=='N'||que[idx]=='?') rec(i-1,j,idx+1);
    if(que[idx]=='S'||que[idx]=='?') rec(i+1,j,idx+1);
    if(que[idx]=='E'||que[idx]=='?') rec(i,j+1,idx+1);
    if(que[idx]=='W'||que[idx]=='?') rec(i,j-1,idx+1);
}
void solve(){
    cin>>n>>m>>q;
    for(int i=0;i<n;i++) cin>>s[i];
    cin>>que;
    ll cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            rec(i,j,0);
        }
    }
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) cnt+=vis[i][j];
    co cnt<<'\n';
}
int main()
{
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1066 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1066 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -