Submission #925624

# Submission time Handle Problem Language Result Execution time Memory
925624 2024-02-12T06:27:14 Z vjudge1 Nautilus (BOI19_nautilus) C++17
29 / 100
2 ms 348 KB
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define no1 cout<<"-1\n"

using namespace std;

const int N = 555;
const int M = 2e5+100;
const int INF = 1e18;
const int mod = 998244353;
  
// int binpow (int a, int n) {
// 	if (n == 0)
// 		return 1;
// 	if (n % 2 == 1)
// 		return (binpow (a, n-1) * a)%mod;
// 	else {
// 		int b = binpow (a, n/2) % mod;
// 		return (b * b)%mod;
// 	}
// }

int n,m,k;
char a[N][N];
string s;
map<char,pair<int,int>> d;

void solve(){
    cin>>n>>m>>k;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    cin>>s;
    vector<pair<int,int>> v;
    int dx = 0;
    int dy = 0;
    v.pb({0,0});
    for(auto x:s){
        dx+=d[x].ff;
        dy+=d[x].ss;
        v.pb({dx,dy});
    }
    // for(auto x:v){
    //     cout<<x.ff<<' '<<x.ss<<'\n';
    // }
    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            bool ok = 1;
            for(auto x:v){
                if(i+x.ff > n || j+x.ss > m || i+x.ff <= 0 || j+x.ss <= 0 || a[i+x.ff][j+x.ss] == '#'){
                    ok = 0;
                    break;
                }
            }
            if(ok){
                // cout<<i<<' '<<j<<'\n';
                ans++;
            }
        }
    }
    cout<<ans<<'\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    d['N'].ff--;
    d['W'].ss--;
    d['S'].ff++;
    d['E'].ss++;
    int t = 1; 
    // cin>>t;
    //   cout<<"";
    for(int i = 1;i<=t;i++){
        solve();
        // cout<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 2 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 2 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -