답안 #970411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970411 2024-04-26T13:38:18 Z Aiperiii Nautilus (BOI19_nautilus) C++14
29 / 100
4 ms 604 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#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=505;
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;
    vector <vector <int> > v1(n,vector <int> (m)),v2(n,vector <int> (m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            if(a[i][j]=='.')v1[i][j]=1;
        }
    }
    
    string s;cin>>s;
    s=' '+s;
    for(int x=0;x<k;x++){
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(!v1[i][j])continue;
                if((s[x+1]=='W' or s[x+1]=='?') && j-1>=0 && a[i][j-1]=='.')v2[i][j-1]=1;
                else if((s[x+1]=='E' or s[x+1]=='?') && j+1<m && a[i][j+1]=='.')v2[i][j+1]=1;
                else if((s[x+1]=='S' or s[x+1]=='?') && i+1<n && a[i+1][j]=='.')v2[i+1][j]=1;
                else if((s[x+1]=='N' or s[x+1]=='?') && i-1>=0 && a[i-1][j]=='.')v2[i-1][j]=1;
            }
        }
        swap(v1,v2);
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                v2[i][j]=0;
            }
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(v1[i][j])cnt++;
        }
    }
    cout<<cnt<<"\n";
}
/*
 5 9 7
 ...##....
 ..#.##..#
 ..#....##
 .##...#..
 ....#....
 WS?EE??
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Incorrect 3 ms 604 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Incorrect 3 ms 604 KB Output isn't correct
8 Halted 0 ms 0 KB -