Submission #1043113

#TimeUsernameProblemLanguageResultExecution timeMemory
1043113biankMaze (JOI23_ho_t3)C++14
0 / 100
1 ms456 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) int(x.size()) const int INF = 1e9; using ii = pair<int, int>; queue<ii> q; int h, w; vector<string> g; vector<vector<bool>> vis; void push(int x, int y) { vis[x][y] = true; q.emplace(x, y); } void expand(string colors, vector<ii> moves, int distance = INF) { while (!q.empty() && distance--) { int s = sz(q); queue<ii> copy = q; while (s--) { auto [x, y] = q.front(); q.pop(); for (auto [dx, dy] : moves) { int nx = x + dx, ny = y + dy; if (nx >= 0 && nx < h && ny >= 0 && ny < w && !vis[nx][ny]) { bool valid = false; for (char c : colors) if (g[nx][ny] == c) valid = true; if (valid) push(nx, ny); } } } if (q.empty()) { q = copy; break; } } } const vector<ii> ALL_MOVES = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; const vector<ii> VERTICAL = {{0, 1}, {0, -1}}; const vector<ii> HORIZONTAL = {{1, 0}, {-1, 0}}; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k, s_r, s_c, g_r, g_c; cin >> h >> w >> k >> s_r >> s_c >> g_r >> g_c; --s_r, --s_c, --g_r, --g_c; g.resize(h); vis.assign(h, vector<bool>(w, false)); for (int i = 0; i < h; i++) cin >> g[i]; push(s_r, s_c); expand(".", ALL_MOVES); int ops = 0; while (!vis[g_r][g_c]) { expand("#", ALL_MOVES, 1); expand(".#", VERTICAL, k - 1); expand(".#", HORIZONTAL, k - 1); expand(".", ALL_MOVES); ops++; } cout << ops << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void expand(std::string, std::vector<std::pair<int, int> >, int)':
Main.cpp:26:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   26 |             auto [x, y] = q.front();
      |                  ^
Main.cpp:28:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |             for (auto [dx, dy] : moves) {
      |                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...