답안 #925592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925592 2024-02-12T05:50:04 Z vjudge1 Nautilus (BOI19_nautilus) C++17
29 / 100
4 ms 468 KB
// By ObeliX
#include <bits/stdc++.h>
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include <unordered_map>
#include <cstddef>
#include <cassert>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;

const long long N = 1e6 + 5;
const long long MOD = 1e7 + 7;
const long long inf = 1e18;

long long n , m , d , k;

int main(){
    //freopen( "cinema.in" , "r" , stdin );
    //freopen( "cinema.out" , "w" , stdout );
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    char c[n+5][m+5];
    for ( int i = 0 ; i <= n + 1 ; i++ ) {
        for ( int j = 0 ; j <= m + 1 ; j++ ) {
            c[i][j] = '.';
        }
    }
    for ( int i = 1 ; i <= n ; i++ ) {
        for ( int j = 1 ; j <= m ; j++ ) {
            cin >> c[i][j];
        }
    }
    string s;
    cin >> s;
    long long ans = 0;
    for ( int i = 1 ; i <= n ; i++ ) {
        for ( int j = 1 ; j <= m ; j++ ) {
            if ( c[i][j] == '.' ) {
                long long x = i;
                long long y = j;
                int can = 0;
                for ( int l = 0 ; l < k ; l++ ) {
                    if ( s[l] == 'W' ) {
                        y--;
                    }
                    else if ( s[l] == 'E' ) {
                        y++;
                    }
                    else if ( s[l] == 'S' ) {
                        x++;
                    }
                    else {
                        x--;
                    }
                    if ( x == 0 || x > n ) {
                        can = 1;
                        break;
                    }
                    if ( y == 0 || y > m ) {
                        can = 1;
                        break;
                    }
                    if ( c[x][y] == '#' ) {
                        can = 1;
                        break;
                    }
                }
                if ( can == 0 ) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 3 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 3 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -