Submission #881928

# Submission time Handle Problem Language Result Execution time Memory
881928 2023-12-02T09:32:45 Z Requiem Nautilus (BOI19_nautilus) C++17
100 / 100
193 ms 160484 KB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
#define INF 1e18
#define fi first
#define se second
#define endl "\n"
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) ((int)(a).size())
#define pi 3.14159265359
#define TASKNAME ""
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } 
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } 
using namespace std; 
typedef pair<int,int> ii; 
typedef pair<int,ii> iii; 
typedef vector<int> vi; 
const int MAXN = 5e2 + 9;
int n,m,k;
char c[MAXN][MAXN];
char dir[MAXN];
bitset<503> dp[5003][MAXN];
bitset<503> sea[MAXN];
main() 
{ 
    fast; 
   if (fopen(TASKNAME".inp","r")){
        freopen(TASKNAME".inp","r",stdin); 
        freopen(TASKNAME".out","w",stdout); 
   } 
   cin>>n>>m>>k;
   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>c[i][j];
           if (c[i][j] == '.') sea[i][j] = 1;
           if (c[i][j] != '#') dp[0][i][j]= 1;
       }
   }
   for(int i=1;i<=k;i++){
       cin>>dir[i];
   }
   int ans = 0;
   for(int t=1;t<=k;t++){
       for(int i=1;i<=n;i++){
           if (dir[t] == 'E') dp[t][i] = (dp[t-1][i] << 1) & sea[i];
           if (dir[t] == 'W') dp[t][i] = (dp[t-1][i] >> 1) & sea[i];
           if (dir[t] == 'S') dp[t][i] = (dp[t-1][i-1]) & sea[i];
           if (dir[t] == 'N') dp[t][i] = (dp[t-1][i+1]) & sea[i];
           if (dir[t] == '?') dp[t][i] = (dp[t-1][i-1] | dp[t-1][i+1] | (dp[t-1][i]<<1) | (dp[t-1][i] >> 1)) & sea[i];
       }
   }
   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           ans += dp[k][i][j];   
       }
   }
   cout<<ans<<endl;



} 

Compilation message

nautilus.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main()
      | ^~~~
nautilus.cpp: In function 'int main()':
nautilus.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(TASKNAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(TASKNAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4568 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4444 KB Output is correct
20 Correct 2 ms 4440 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4568 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4444 KB Output is correct
20 Correct 2 ms 4440 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 119 ms 160340 KB Output is correct
23 Correct 97 ms 160320 KB Output is correct
24 Correct 103 ms 160340 KB Output is correct
25 Correct 90 ms 160184 KB Output is correct
26 Correct 90 ms 160484 KB Output is correct
27 Correct 145 ms 160360 KB Output is correct
28 Correct 149 ms 160336 KB Output is correct
29 Correct 148 ms 160332 KB Output is correct
30 Correct 151 ms 160452 KB Output is correct
31 Correct 145 ms 160100 KB Output is correct
32 Correct 190 ms 160336 KB Output is correct
33 Correct 189 ms 160352 KB Output is correct
34 Correct 193 ms 160340 KB Output is correct
35 Correct 190 ms 160180 KB Output is correct
36 Correct 189 ms 160336 KB Output is correct