Submission #925684

#TimeUsernameProblemLanguageResultExecution timeMemory
925684vjudge1Nautilus (BOI19_nautilus)C++17
66 / 100
1042 ms1440 KiB
#include<iostream> #include<cassert> #include<cmath> #include<cstring> #include<algorithm> #include<vector> #include<stack> #include<set> #include<queue> #include<map> using namespace std; const int N = (int)4e5 + 7; const int inf = (int)1e9 + 7; const int MOD = (int)998244353; const long long INF = (long long)1e18 + 7; int mult(int x, int y) { return 1ll*x*y%MOD; } int sum(int x, int y) { x += y; if(x >= MOD) { x -= MOD; } return x; } int sub(int x, int y) { x -= y; if(x < 0) { x += MOD; } return x; } int n, m, k; vector<pair<int, int> > dir[300]; void init() { dir['W'] = {{0, -1}}; dir['E'] = {{0, +1}}; dir['N'] = {{-1, 0}}; dir['S'] = {{+1, 0}}; dir['?'] = {{0, -1}, {0, +1}, {-1, 0}, {+1, 0}}; } int main() { ios_base::sync_with_stdio(NULL); cin.tie(0); init(); cin >> n >> m >> k; char a[n+1][m+1]; bool is[n+1][m+1]; bool used[2][n+1][m+1]; memset(used, 0, sizeof(used)); memset(is, 0, sizeof(is)); for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { cin >> a[i][j]; } } string s; cin >> s; s = '#'+s; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { if(a[i][j] == '.') { used[0][i][j] = 1; } } } for(int id = 0; id < k; ++id) { for(int x = 1; x <= n; ++x) { for(int y = 1; y <= m; ++y) { if(!used[0][x][y]) { continue; } for(auto e : dir[s[id+1]]) { int tox = x+e.first; int toy = y+e.second; if(tox<1 || tox>n || toy<1 || toy>m || a[tox][toy] == '#') { continue; } used[1][tox][toy] = 1; } } } for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { swap(used[0][i][j], used[1][i][j]); used[1][i][j] = 0; } } } int ans = 0; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { ans += used[0][i][j]; } } cout << ans << "\n"; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:82:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   82 |     for(auto e : dir[s[id+1]]) {
      |                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...