Submission #159632

#TimeUsernameProblemLanguageResultExecution timeMemory
159632DrSwadNautilus (BOI19_nautilus)C++17
66 / 100
1084 ms64720 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #endif typedef long long ll; typedef unsigned int uint; typedef pair<int, int> pii; #define x first #define y second #define size(a) (int)a.size() const int N = 505, M = 5005; enum dir { UP, RIGHT, DOWN, LEFT, ALL }; int r, c, m; char cell[N][N]; bool vis[M][N][N]; dir moves[M]; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; int main() { #ifdef LOCAL freopen("in", "r", stdin); freopen("out", "w", stdout); #endif scanf("%d %d %d", &r, &c, &m); for (int i = 1; i <= r; i++) { scanf("%s", cell[i] + 1); } char s[M]; scanf("%s", s + 1); for (int i = 1; i <= m; i++) { switch (s[i]) { case 'N': moves[i] = UP; break; case 'E': moves[i] = RIGHT; break; case 'S': moves[i] = DOWN; break; case 'W': moves[i] = LEFT; break; default: moves[i] = ALL; break; } } for (int _r = 1; _r <= r; _r++) { for (int _c = 1; _c <= c; _c++) { vis[0][_r][_c] = cell[_r][_c] == '.'; } } for (int i = 1; i <= m; i++) { for (int _r = 1; _r <= r; _r++) { for (int _c = 1; _c <= c; _c++) { if (!vis[i - 1][_r][_c]) continue; for (int d = 0; d < 4; d++) { if (d != moves[i] && moves[i] != ALL) continue; int _x = _r + dx[d]; int _y = _c + dy[d]; if (_x < 1 || r < _x || _y < 1 || c < _y || cell[_x][_y] != '.') continue; vis[i][_x][_y] = true; } } } } cout << accumulate(&vis[m][0][0], &vis[m][0][0] + sizeof(vis[m]), 0) << endl; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &r, &c, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", cell[i] + 1);
   ~~~~~^~~~~~~~~~~~~~~~~~~
nautilus.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", s + 1);
  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...