Submission #593605

#TimeUsernameProblemLanguageResultExecution timeMemory
593605nguyentuNautilus (BOI19_nautilus)C++14
66 / 100
92 ms262144 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; #define ii pair<int , int> #define iv pair<ii , ii> #define iii pair<int , ii> #define fi first #define se second #define int long long const int inf = 1e18 + 7; const int MAX_N = 5e2 + 7; const int MOD = 1e9 + 7; char a[MAX_N][MAX_N]; int f[MAX_N][MAX_N][950]; char s[5007]; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n , m , l; cin >> n >> m >> l; for (int i = 1 ; i <= n ; i++) { for (int j = 1 ; j <= m ; j++) { cin >> a[i][j]; } } for (int i = 1 ; i <= n ; i++) { for (int j = 1 ; j <= m ; j++) { if (a[i][j] != '#') { f[i][j][0] = 1; } } } for (int i = 1 ; i <= l ; i++) { cin >> s[i]; } for (int h = 1 ; h <= l ; h++) { for (int i = 1 ; i <= n ;i ++) { for (int j = 1 ; j <= m ; j++) { if (a[i][j] == '#') continue;; if (s[h] == 'W' && j < m) { f[i][j][h] = f[i][j + 1][h - 1]; } if (s[h] == 'N' && i < n) { f[i][j][h] = f[i + 1][j][h - 1]; } if (s[h] == 'E' && 1 < j) { f[i][j][h] = f[i][j - 1][h - 1]; } if (s[h] == 'S' && 1 < i) { f[i][j][h] = f[i - 1][j][h - 1]; } if (s[h] == '?') { if (j < m && f[i][j + 1][h - 1]) f[i][j][h] = f[i][j + 1][h - 1]; if (i < n && f[i + 1][j][h - 1]) f[i][j][h] = f[i + 1][j][h - 1]; if (1 < j && f[i][j - 1][h - 1]) f[i][j][h] = f[i][j - 1][h - 1]; if (1 < i && f[i - 1][j][h - 1]) f[i][j][h] = f[i - 1][j][h - 1]; } } } } int ans = 0; int cnt = 0; for (int i = 1 ; i <= n ;i ++) { for (int j = 1 ; j <= m ; j++) { if (f[i][j][l]) { ans++; } //cout << f[i][j][l] << " "; } //cout << '\n'; } cout << ans; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:67:9: warning: unused variable 'cnt' [-Wunused-variable]
   67 |     int cnt = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...