Submission #314080

#TimeUsernameProblemLanguageResultExecution timeMemory
314080BeanZNautilus (BOI19_nautilus)C++14
100 / 100
211 ms768 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 505; bitset<N> a[N], dp[N][2]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll r, c, m; cin >> r >> c >> m; for (int i = 1; i <= r; i++){ for (int j = 1; j <= c; j++){ char s; cin >> s; if (s == '.') a[i][j] = 1; } dp[i][0] = a[i]; //cout << dp[i][0] << endl; } string s; cin >> s; for (int i = 0; i < m; i++){ for (int j = 1; j <= r; j++){ if (s[i] == 'N') dp[j][(i + 1) & 1] = dp[j + 1][i & 1]; if (s[i] == 'W') dp[j][(i + 1) & 1] = dp[j][i & 1] >> 1; if (s[i] == 'E') dp[j][(i + 1) & 1] = dp[j][i & 1] << 1; if (s[i] == 'S') dp[j][(i + 1) & 1] = dp[j - 1][i & 1]; if (s[i] == '?') dp[j][(i + 1) & 1] = dp[j - 1][i & 1] | dp[j + 1][i & 1] | (dp[j][i & 1] >> 1) | (dp[j][i & 1] << 1); dp[j][(i + 1) & 1] &= a[j]; //cout << j << " " << i << " " << dp[j][i & 1] << endl; } } ll ans = 0; for (int i = 1; i <= r; i++){ ans = ans + dp[i][m & 1].count(); } cout << ans; } /* 2 3 3 ..# #.# ?S? */

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...