Submission #752593

#TimeUsernameProblemLanguageResultExecution timeMemory
752593penguin133Nautilus (BOI19_nautilus)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int r, c, m; bitset <500> ok[501], ok2[501], ok3[501], ok4[501]; char G[501][501]; string s; int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; void solve(){ cin >> r >> c >> m; for(int i=1;i<=r;i++)for(int j=1;j<=c;j++)cin >> G[i][j]; queue <pi> q; for(int i=1;i<=r;i++)for(int j=1;j<=c;j++){ if(G[i][j] == '.'){ ok[i][j - 1] = 1; ok3[j][i - 1] = 1; } } cin >> s; for(int a = 0; a < m; a++){ for(int i = 1; i <= r; i++)ok2[i].reset(); for(int i = 1; i <= c; i++)ok4[i].reset(); if(s[a] == 'W' || s[a] == '?'){ for(int i = 1; i <= r; i++)ok2[i] |= (ok[i] >> 1); } if(s[a] == 'E' || s[a] == '?'){ for(int i = 1; i <= r; i++)ok2[i] |= (ok[i] << 1); } if(s[a] == 'S' || s[a] == 'N')for(int i = 1; i <= r; i++)ok2[i] = ok[i]; if(s[a] == 'W' || s[a] == 'E')for(int i = 1; i <= c; i++)ok4[i] = ok3[i]; if(s[a] == 'S' || s[a] == '?'){ for(int i = 1; i <= c; i++)ok4[i] |= (ok3[i] << 1); } if(s[a] == 'N' || s[a] == '?'){ for(int i = 1; i <= c; i++)ok4[i] |= (ok3[i] >> 1); } for(int i = 1; i <= r; i++)ok[i] = ok2[i]; for(int i = 1; i <= c; i++)ok3[i] = ok4[i]; } int ans = 0; for(int i=1;i<=r;i++)for(int j=1;j<=c;j++)ans += (ok[i][j - 1] | ok3[j][i - 1]); cout << ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

nautilus.cpp:58:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 |     main(){
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...