Submission #925929

# Submission time Handle Problem Language Result Execution time Memory
925929 2024-02-12T10:58:22 Z vjudge1 Nautilus (BOI19_nautilus) C++17
66 / 100
172 ms 19724 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;
long long dp[105][105][105];

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;
    for ( int i = 1 ; i <= n ; i++ ) {
        for ( int j = 1 ; j <= m ; j++ ) {
            if ( c[i][j] == '.' ) {
                dp[0][i][j] = 1;
            }
        }
    }
    for ( int l = 0 ; l < k ; l++ ) {
        for ( int i = 1 ; i <= n ; i++ ) {
            for ( int j = 1 ; j <= m ; j++ ) {
                if ( c[i][j] != '.' ) {
                    continue;
                }
                if ( s[l] == 'W' || s[l] == '?' ) {
                    dp[l+1][i][j] = max( dp[l+1][i][j] , dp[l][i][j+1] );
                }
                if ( s[l] == 'E' || s[l] == '?' ) {
                    dp[l+1][i][j] = max( dp[l+1][i][j] , dp[l][i][j-1] );
                }
                if ( s[l] == 'S' || s[l] == '?' ) {
                    dp[l+1][i][j] = max( dp[l+1][i][j] , dp[l][i-1][j] );
                }
                if ( s[l] == 'N' || s[l] == '?' ) {
                    dp[l+1][i][j] = max( dp[l+1][i][j] , dp[l][i+1][j] );
                }
            }
        }
    }
    long long ans = 0;
    for ( int i = 1 ; i <= n ; i++ ) {
        for ( int j = 1 ; j <= m ; j++ ) {
            if ( dp[k][i][j] == 1 ) {
                ans++;
            }
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9048 KB Output is correct
2 Correct 10 ms 9052 KB Output is correct
3 Correct 10 ms 9052 KB Output is correct
4 Correct 10 ms 9048 KB Output is correct
5 Correct 7 ms 9052 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9048 KB Output is correct
2 Correct 10 ms 9052 KB Output is correct
3 Correct 10 ms 9052 KB Output is correct
4 Correct 10 ms 9048 KB Output is correct
5 Correct 7 ms 9052 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 9 ms 9048 KB Output is correct
8 Correct 10 ms 9052 KB Output is correct
9 Correct 10 ms 9008 KB Output is correct
10 Correct 7 ms 9052 KB Output is correct
11 Correct 2 ms 1372 KB Output is correct
12 Correct 12 ms 9052 KB Output is correct
13 Correct 12 ms 9132 KB Output is correct
14 Correct 12 ms 9052 KB Output is correct
15 Correct 7 ms 9460 KB Output is correct
16 Correct 2 ms 1368 KB Output is correct
17 Correct 13 ms 9124 KB Output is correct
18 Correct 12 ms 9052 KB Output is correct
19 Correct 11 ms 9144 KB Output is correct
20 Correct 8 ms 9052 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9048 KB Output is correct
2 Correct 10 ms 9052 KB Output is correct
3 Correct 10 ms 9052 KB Output is correct
4 Correct 10 ms 9048 KB Output is correct
5 Correct 7 ms 9052 KB Output is correct
6 Correct 2 ms 1884 KB Output is correct
7 Correct 9 ms 9048 KB Output is correct
8 Correct 10 ms 9052 KB Output is correct
9 Correct 10 ms 9008 KB Output is correct
10 Correct 7 ms 9052 KB Output is correct
11 Correct 2 ms 1372 KB Output is correct
12 Correct 12 ms 9052 KB Output is correct
13 Correct 12 ms 9132 KB Output is correct
14 Correct 12 ms 9052 KB Output is correct
15 Correct 7 ms 9460 KB Output is correct
16 Correct 2 ms 1368 KB Output is correct
17 Correct 13 ms 9124 KB Output is correct
18 Correct 12 ms 9052 KB Output is correct
19 Correct 11 ms 9144 KB Output is correct
20 Correct 8 ms 9052 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Runtime error 172 ms 19724 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -