Submission #496450

#TimeUsernameProblemLanguageResultExecution timeMemory
496450NalrimetNautilus (BOI19_nautilus)C++17
100 / 100
204 ms157040 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5 * 1e2 + 5; const int inf = 1000000000; #define int long long #define F first #define S second #define pb push_back #define ppb pop_back int r, c, m, ans; char f, s; bitset<N> dp[N][5005]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> r >> c >> m; for(int i = 1; i <= r; ++i){ for(int j = 1; j <= c; ++j){ dp[i][0][j - 1] = 1; cin >> f; if(f == '#') dp[i][0][j - 1] = 0; } // cout << dp[i][0] << '\n'; } for(int k = 1; k <= m; ++k){ cin >> s; for(int i = 1; i <= r; ++i){ dp[i][k] = dp[i][0]; if(s == 'N'){ dp[i][k] &= dp[i + 1][k - 1]; } else if(s == 'S'){ dp[i][k] &= dp[i - 1][k - 1]; } else if(s == 'E'){ dp[i][k] &= dp[i][k - 1] << 1; } else if(s == 'W'){ dp[i][k] &= dp[i][k - 1] >> 1; } else{ dp[i][k] &= (dp[i][k - 1] << 1) | (dp[i][k - 1] >> 1) | (dp[i - 1][k - 1]) | (dp[i + 1][k - 1]); } } } // 5 9 7 // ...##.... // ..#.##..# // ..#....## // .##...#.. // ....#.... // WS?EE?? for(int i = 1; i <= r; ++i){ // cout << dp[i][m] << '\n'; ans += dp[i][m].count(); } cout << ans; return 0; }

Compilation message (stderr)

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