Submission #925762

# Submission time Handle Problem Language Result Execution time Memory
925762 2024-02-12T08:30:21 Z vjudge1 Nautilus (BOI19_nautilus) C++17
29 / 100
1000 ms 348 KB
/*
no more temmy :(
*/

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=510;
const int M=1e6;
const int B=317;
const int mod=998244353;
const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,m,k;
char a[N][N];
int rv[N];
string s;
bool check(int x,int y){
    if(x<1||y<1||x>n||y>m||a[x][y]=='#')return 0;
    return 1;
}

int add(int xz,int yz,int e){
    if(e==k){
        return 1;
    }
    if(s[e]=='?'){
        for(int i=0;i<4;i++){
            int x=xz+dx[i];
            int y=yz+dy[i];
            if(check(x,y)){
                if(add(x,y,e+1)){
                    return 1;
                }
            }
        }
        return 0;
    }
    xz+=dx[rv[s[e]]];
    yz+=dy[rv[s[e]]];
    if(check(xz,yz)){
        if(add(xz,yz,e+1)){
            return 1;
        }
        return 0;
    }
    return 0;

}
void test(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    cin>>s;
    reverse(s.begin(),s.end());
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='.'){
                if(add(i,j,0)){
                    ans++;
                    // cout<<i<<' '<<j<<'\n';
                }
            }
        }
    }
    cout<<ans<<'\n';
}
/*

*/  
 
signed main(){
    rv['N']=0;
    rv['S']=1;
    rv['W']=2;
    rv['E']=3;
    // ic.prefix("debug->| ");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    long long t2=1;
    //  cin>>t2;
    for(int i=1;i<=t2;i++){
        test();
    }
    
    return 0;
 
}

Compilation message

nautilus.cpp: In function 'long long int add(long long int, long long int, long long int)':
nautilus.cpp:54:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   54 |     xz+=dx[rv[s[e]]];
      |                   ^
nautilus.cpp:55:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |     yz+=dy[rv[s[e]]];
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 1 ms 344 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 5 ms 344 KB Output is correct
2 Correct 1 ms 344 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 Correct 8 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
14 Execution timed out 1069 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 1 ms 344 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 Correct 8 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 9 ms 348 KB Output is correct
14 Execution timed out 1069 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -