Submission #608826

# Submission time Handle Problem Language Result Execution time Memory
608826 2022-07-27T10:33:39 Z MohamedFaresNebili Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 20524 KB
#include <bits/stdc++.h>
#include "wombats.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")

            using namespace std;

            using ll = long long;
            using ii = pair<ll, ll>;
            using vi = vector<int>;
            using pi = pair<int, pair<int, int>>;

            #define ff first
            #define ss second
            #define pb push_back
            #define all(x) (x).begin(), (x).end()
            #define lb lower_bound

            const int oo = 1000 * 1000 * 1000 + 7;

            int R, C, H[5000][200], K[5000][200], DP[100][100];
            bool pr[100];
            void precomputation(int i) {
                priority_queue<pi, vector<pi>, greater<pi>> pq;
                pq.push({0, {0, i}}); vector<vector<int>> D;
                D = vector<vector<int>> (R, vector<int>(C, oo));
                vector<vector<bool>> vis(R, vector<bool>(C, 0));
                D[0][i] = 0;
                while(!pq.empty()) {
                    int U = pq.top().ss.ff, V = pq.top().ss.ss;
                    int W = pq.top().ff; pq.pop();
                    if(W != D[U][V] || vis[U][V]) continue;
                    vis[U][V] = 1;
                    if(V < C - 1) {
                        if(!vis[U][V + 1] && D[U][V + 1] > D[U][V] + H[U][V]) {
                            D[U][V + 1] = D[U][V] + H[U][V];
                            pq.push({D[U][V + 1], {U, V + 1}});
                        }
                    }
                    if(V > 0) {
                        if(!vis[U][V - 1] && D[U][V - 1] > D[U][V] + H[U][V - 1]) {
                            D[U][V - 1] = D[U][V] + H[U][V - 1];
                            pq.push({D[U][V - 1], {U, V - 1}});
                        }
                    }
                    if(U < R - 1) {
                        if(!vis[U + 1][V] && D[U + 1][V] > D[U][V] + K[U][V]) {
                            D[U + 1][V] = D[U][V] + K[U][V];
                            pq.push({D[U + 1][V], {U + 1, V}});
                        }
                    }
                }
                for(int l = 0; l < C; l++)
                    DP[i][l] = D[R - 1][l];
                pr[i] = 1;
            }
            void init(int r, int c, int h[5000][200], int v[5000][200]) {
                R = r, C = c;
                for(int l = 0; l < R; l++)
                    for(int i = 0; i < C; i++)
                        H[l][i] = h[l][i],
                        K[l][i] = v[l][i];
                for(int l = 0; l < C; l++)
                    precomputation(l);
            }

            void changeH(int P, int Q, int W) {
                H[P][Q] = W;
                for(int l = 0; l < C; l++) pr[l] = 0;
            }
            void changeV(int P, int Q, int W) {
                K[P][Q] = W;
                for(int l = 0; l < C; l++) pr[l] = 0;
            }

            int escape(int V1, int V2) {
                if(!pr[V1]) precomputation(V1);
                return DP[V1][V2];
            }

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 277 ms 12688 KB Output is correct
2 Correct 297 ms 12688 KB Output is correct
3 Correct 341 ms 14192 KB Output is correct
4 Correct 301 ms 12672 KB Output is correct
5 Correct 259 ms 12668 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 62 ms 1352 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 230 ms 844 KB Output is correct
2 Correct 424 ms 1048 KB Output is correct
3 Correct 262 ms 828 KB Output is correct
4 Correct 260 ms 964 KB Output is correct
5 Correct 288 ms 728 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 291 ms 760 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 940 ms 16576 KB Output is correct
2 Correct 1621 ms 16708 KB Output is correct
3 Correct 913 ms 16584 KB Output is correct
4 Correct 1000 ms 17328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 234 ms 728 KB Output is correct
2 Correct 416 ms 880 KB Output is correct
3 Correct 263 ms 712 KB Output is correct
4 Correct 267 ms 732 KB Output is correct
5 Correct 280 ms 720 KB Output is correct
6 Correct 903 ms 16528 KB Output is correct
7 Correct 1613 ms 16596 KB Output is correct
8 Correct 982 ms 16564 KB Output is correct
9 Correct 964 ms 17324 KB Output is correct
10 Correct 292 ms 12688 KB Output is correct
11 Correct 302 ms 12700 KB Output is correct
12 Correct 322 ms 14200 KB Output is correct
13 Correct 259 ms 12688 KB Output is correct
14 Correct 294 ms 12668 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 70 ms 1372 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 305 ms 724 KB Output is correct
28 Execution timed out 20049 ms 18520 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 228 ms 724 KB Output is correct
2 Correct 420 ms 880 KB Output is correct
3 Correct 277 ms 832 KB Output is correct
4 Correct 258 ms 704 KB Output is correct
5 Correct 272 ms 828 KB Output is correct
6 Correct 917 ms 16568 KB Output is correct
7 Correct 1628 ms 16596 KB Output is correct
8 Correct 906 ms 16572 KB Output is correct
9 Correct 957 ms 17284 KB Output is correct
10 Correct 300 ms 12664 KB Output is correct
11 Correct 312 ms 12696 KB Output is correct
12 Correct 336 ms 14196 KB Output is correct
13 Correct 277 ms 12688 KB Output is correct
14 Correct 276 ms 12660 KB Output is correct
15 Incorrect 10512 ms 20524 KB Output isn't correct
16 Halted 0 ms 0 KB -