제출 #1283839

#제출 시각아이디문제언어결과실행 시간메모리
1283839red_soulsNautilus (BOI19_nautilus)C++20
100 / 100
203 ms157308 KiB
#include <bits/stdc++.h> #define ll long long #define task "nautilus" using namespace std; const int N = 516; int n, m, q; char a[N][N], d[5016]; namespace sub3 { bitset <502> sea[N], dp[502][5001]; int result; void solve() { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] == '.') { sea[i].set(j - 1); } } } for (int i = 1; i <= n; i++) { dp[i][0] = sea[i]; } for (int t = 1; t <= q; t++) { for (int i = 1; i <= n; i++) { if (d[t] == 'N') { dp[i][t] = dp[i + 1][t - 1] & sea[i]; } if (d[t] == 'S') { dp[i][t] = dp[i - 1][t - 1] & sea[i]; } if (d[t] == 'E') { dp[i][t] = (dp[i][t - 1] << 1) & sea[i]; } if (d[t] == 'W') { dp[i][t] = (dp[i][t - 1] >> 1) & sea[i]; } if (d[t] == '?') { dp[i][t] = (dp[i - 1][t - 1] | dp[i + 1][t - 1] | (dp[i][t - 1] << 1) | (dp[i][t - 1] >> 1)) & sea[i]; } } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { result += dp[i][q][j - 1]; } } cout << result; } } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n >> m >> q; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= q; i++) { cin >> d[i]; } sub3 :: solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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