Submission #969967

# Submission time Handle Problem Language Result Execution time Memory
969967 2024-04-26T02:46:32 Z Aiperiii Nautilus (BOI19_nautilus) C++14
29 / 100
482 ms 262144 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=105;
char a[N][N];
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    string s;cin>>s;
    set <pair <int,int> > st;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]=='#')continue;
            queue <vector <int> > q;
            q.push({i,j,-1});
            while(!q.empty()){
                int x=q.front()[0];
                int y=q.front()[1];
                int ind=q.front()[2];
                q.pop();
                ind++;
                if(ind==k){
                    st.insert({x,y});
                    continue;
                }
                if(s[ind]=='W' && y-1>=0 && a[x][y-1]=='.')q.push({x,y-1,ind});
                if(s[ind]=='E' && y+1<m && a[x][y+1]=='.')q.push({x,y+1,ind});
                if(s[ind]=='S' && x+1<n && a[x+1][y]=='.')q.push({x+1,y,ind});
                if(s[ind]=='N' && x-1>=0 && a[x-1][y]=='.')q.push({x-1,y,ind});
                if(s[ind]=='?'){
                    if(y-1>=0 && a[x][y-1]=='.')q.push({x,y-1,ind});
                    if(y+1<m && a[x][y+1]=='.')q.push({x,y+1,ind});
                    if(x-1>=0 && a[x-1][y]=='.')q.push({x-1,y,ind});
                    if(x+1<n && a[x+1][y]=='.')q.push({x+1,y,ind});
                }
            }
        }
    }
    cout<<st.size()<<"\n";
}
/*
 5 9 7
 ...##....
 ..#.##..#
 ..#....##
 .##...#..
 ....#....
 WS?EE??
 */
# Verdict Execution time Memory Grader output
1 Correct 21 ms 864 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 864 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 482 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 864 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 482 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -