답안 #608762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
608762 2022-07-27T09:56:18 Z MohamedFaresNebili 웜뱃 (IOI13_wombats) C++14
0 / 100
20000 ms 16508 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>;

            #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], ST[500005];
            void build(int v, int l, int r) {
                if(l == r) {
                    ST[v] = K[l][0];
                    return;
                }
                build(v * 2, l, (l + r) / 2);
                build(v * 2 + 1, (l + r) / 2 + 1, r);
                ST[v] = ST[v * 2] + ST[v * 2 + 1];
            }
            void update(int v, int l, int r, int p, int val) {
                if(l == r) {
                    ST[v] = val;
                    return;
                }
                int md = (l + r) / 2;
                if(p <= md)
                    update(v * 2, l, md, p, val);
                else update(v * 2 + 1, md + 1, r, p, val);
                ST[v] = ST[v * 2] + ST[v * 2 + 1];
            }
            int query(int v, int l, int r, int lo, int hi) {
                if(l > hi || r < lo) return 0;
                if(l >= lo && r <= hi)
                    return ST[v];
                return query(v * 2, l, (l + r) / 2, lo, hi)
                    +  query(v * 2 + 1, (l + r) / 2 + 1, r, lo, hi);
            }
            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];
                if(C == 1) build(1, 0, R - 2);
            }

            void changeH(int P, int Q, int W) { H[P][Q] = W; }
            void changeV(int P, int Q, int W) {
                K[P][Q] = W;
                if(C == 1) update(1, 0, R - 2, P, W);
            }

            using pi = pair<int, pair<int, int>>;

            int escape(int V1, int V2) {
                if(C == 1)
                    return query(1, 0, R - 2, V1, V2 - 1);
                priority_queue<pi, vector<pi>, greater<pi>> pq;
                pq.push({0, {0, V1}}); vector<vector<int>> D;
                D = vector<vector<int>> (R, vector<int>(C, oo));
                D[0][V1] = 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]) continue;
                    if(V < C - 1) {
                        if(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(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(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}});
                        }
                    }
                }
                return D[R - 1][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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12116 KB Output is correct
2 Incorrect 6 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 688 KB Output is correct
2 Correct 224 ms 876 KB Output is correct
3 Correct 117 ms 688 KB Output is correct
4 Correct 126 ms 684 KB Output is correct
5 Correct 133 ms 684 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 659 ms 16348 KB Output is correct
2 Correct 1201 ms 16240 KB Output is correct
3 Correct 602 ms 16220 KB Output is correct
4 Execution timed out 20046 ms 16508 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 696 KB Output is correct
2 Correct 206 ms 844 KB Output is correct
3 Correct 119 ms 596 KB Output is correct
4 Correct 120 ms 700 KB Output is correct
5 Correct 122 ms 680 KB Output is correct
6 Correct 604 ms 16224 KB Output is correct
7 Correct 1269 ms 16360 KB Output is correct
8 Correct 585 ms 16212 KB Output is correct
9 Execution timed out 20037 ms 16504 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 596 KB Output is correct
2 Correct 217 ms 924 KB Output is correct
3 Correct 138 ms 684 KB Output is correct
4 Correct 129 ms 684 KB Output is correct
5 Correct 119 ms 688 KB Output is correct
6 Correct 663 ms 16344 KB Output is correct
7 Correct 1308 ms 16240 KB Output is correct
8 Correct 672 ms 16220 KB Output is correct
9 Execution timed out 20063 ms 16504 KB Time limit exceeded
10 Halted 0 ms 0 KB -