Submission #1256014

#TimeUsernameProblemLanguageResultExecution timeMemory
1256014comgaTramAnh웜뱃 (IOI13_wombats)C++20
37 / 100
20079 ms20728 KiB
#include <bits/stdc++.h> #include "wombats.h" using namespace std; long long sum = 0LL; int h[5000][200]; int v[5000][200]; int f[5000][200]; int n, m; void init(int R, int C, int H[5000][200], int V[5000][200]) { n = R; m = C; for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { h[i][j] = H[i][j]; v[i][j] = V[i][j]; } } } void changeH(int P, int Q, int W) { h[P][Q] = W; } void changeV(int P, int Q, int W) { v[P][Q] = W; } int escape(int V1, int V2) { const int inf = 1000000007; priority_queue <tuple <int, int, int>, vector <tuple <int, int, int>>, greater <tuple <int, int, int>>> pq; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { f[i][j] = inf; } } f[0][V1] = 0; pq.push(make_tuple(f[0][V1], 0, V1)); while (pq.empty() == false) { tuple <int, int, int> element = pq.top(); pq.pop(); int dist = get <0>(element); int i = get <1>(element); int j = get <2>(element); if (f[i][j] != dist) { continue; } if (j > 0) { if (f[i][j - 1] > f[i][j] + h[i][j - 1]) { f[i][j - 1] = f[i][j] + h[i][j - 1]; pq.push(make_tuple(f[i][j - 1], i, j - 1)); } } if (j < m - 1) { if (f[i][j + 1] > f[i][j] + h[i][j]) { f[i][j + 1] = f[i][j] + h[i][j]; pq.push(make_tuple(f[i][j + 1], i, j + 1)); } } if (i < n - 1) { if (f[i + 1][j] > f[i][j] + v[i][j]) { f[i + 1][j] = f[i][j] + v[i][j]; pq.push(make_tuple(f[i + 1][j], i + 1, j)); } } } return f[n - 1][V2]; }
#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...