Submission #1080977

#TimeUsernameProblemLanguageResultExecution timeMemory
1080977raphaelpText editor (CEOI24_editor)C++14
14 / 100
3886 ms21308 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int debx, deby, finx, finy; cin >> debx >> deby >> finx >> finy; debx--, deby--, finx--, finy--; vector<int> Tab(N); for (int i = 0; i < N; i++) cin >> Tab[i]; vector<vector<int>> occ(N, vector<int>(5001)); priority_queue<vector<int>> PQ; PQ.push({0, debx, deby}); while (!PQ.empty()) { int x = PQ.top()[1], y = PQ.top()[2], t = PQ.top()[0]; PQ.pop(); if (occ[x][y]) continue; occ[x][y] = 1; if (x == finx && y == finy) { cout << -t; return 0; } if (y > 0) PQ.push({t - 1, x, y - 1}); if (y < Tab[x]) PQ.push({t - 1, x, y + 1}); if (x > 0 && y == 0) PQ.push({t - 1, x - 1, Tab[x - 1]}); if (x < N - 1 && y == Tab[x]) PQ.push({t - 1, x + 1, 0}); if (x < N - 1) PQ.push({t - 1, x + 1, min(y, Tab[x + 1])}); if (x > 0) PQ.push({t - 1, x - 1, min(y, Tab[x - 1])}); } }
#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...