제출 #687493

#제출 시각아이디문제언어결과실행 시간메모리
687493stanislavpolynNautilus (BOI19_nautilus)C++17
0 / 100
2 ms468 KiB
#include <bits/stdc++.h> #define fr(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, a, b) for (int i = (a); i >= (b); --i) #define fe(x, y) for (auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define all(x) (x).begin(), (x).end() #define pw(x) (1LL << (x)) #define sz(x) (int)(x).size() using namespace std; mt19937_64 rng(228); #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template <typename T> bool umn(T& a, T b) { return a > b ? a = b, 1 : 0; } template <typename T> bool umx(T& a, T b) { return a < b ? a = b, 1 : 0; } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using ve = vector<T>; const int N = 505; const int dx[] = {1 -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; const string d = "SNEW"; int n, m, k; char a[N][N]; string s; bool dp[N][N], ndp[N][N]; bool valid(int x, int y) { return x >= 1 && y >= 1 && x <= n && y <= m && a[x][y] != '#'; } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> m >> k; fr (i, 1, n) { fr (j, 1, m) { cin >> a[i][j]; } } cin >> s; fr (i, 1, n) { fr (j, 1, m) { if (a[i][j] != '#') { dp[i][j] = 1; } } } fr (step, 0, sz(s) - 1) { int p = find(all(d), s[step]) - d.begin(); fr (i, 1, n) { fr (j, 1, m) { if (dp[i][j]) { if (p != sz(d)) { if (valid(i + dx[p], j + dy[p])) { ndp[i + dx[p]][j + dy[p]] = 1; } } else { fr (cur, 0, 3) { if (valid(i + dx[cur], j + dy[cur])) { ndp[i + dx[cur]][j + dy[cur]] = 1; } } } } } } fr (i, 1, n) { fr (j, 1, m) { dp[i][j] = ndp[i][j]; ndp[i][j] = 0; } } } int ans = 0; fr (i, 1, n) { fr (j, 1, m) { if (dp[i][j]) { ans++; } } } cout << ans << "\n"; return 0; }

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

nautilus.cpp: In function 'int main()':
nautilus.cpp:100:49: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations]
  100 |                             if (valid(i + dx[cur], j + dy[cur])) {
      |                                           ~~~~~~^
nautilus.cpp:3:41: note: within this loop
    3 | #define fr(i, a, b) for (int i = (a); i <= (b); ++i)
      |                                         ^
nautilus.cpp:99:25: note: in expansion of macro 'fr'
   99 |                         fr (cur, 0, 3) {
      |                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...