Submission #646170

# Submission time Handle Problem Language Result Execution time Memory
646170 2022-09-28T21:22:23 Z eNGy Circus (Balkan15_CIRCUS) C++17
49 / 100
3179 ms 524288 KB
#include "circus.h"
#include <bits/stdc++.h>
#define c(x) (cerr << __LINE__ << ": " << #x << ' ' << (x) << endl, (x))
#define vis() (cerr << __LINE__ << endl)
#define ll long long
#define f first
#define s second
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using namespace std;

vector<int> X, L;
int n;

void init(int N, int M, int P[]){
    n = N;
    for(int i=0; i<N; i++){
        X.pb(P[i]);
    }
    X.pb(M);

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    L.resize(N+1, 1e9);
    L[N] = 0;

    pq.push({0, N});

    while(!pq.empty()){
        int v = pq.top().s, l = pq.top().f;
        pq.pop();

        //c(v); c(l);

        if(L[v] != l) continue;

        for(int i=0; i<n; i++){
            if(abs(X[i] - X[v]) >= L[v]){
                if(L[i] > abs(X[i] - X[v])){
                    L[i] = abs(X[i] - X[v]);
                    pq.push({L[i], i});
                }
            }
        }

        //for(int l: L) cout << l << ' '; cout << endl;
    }

    //for(int l: L) cout << l << ' '; cout << endl;
}

int minLength(int D) {
    int l = X[n] - D;

    for(int i=0; i<n; i++){
        if(X[i] == D)
            return L[i];
        
        if(abs(X[i] - D) >= L[i]){
            l = min(l, abs(X[i] - D));
        }
    }

    return l;
}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:14:12: warning: unused variable 'max_code' [-Wunused-variable]
   14 |  long long max_code;
      |            ^~~~~~~~
grader.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
grader.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &P[i]);
      |   ~~~~~^~~~~~~~~~~~~
grader.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &Q);
      |  ~~~~~^~~~~~~~~~
grader.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d", &d);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2332 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 50 ms 2532 KB Output is correct
6 Correct 53 ms 4528 KB Output is correct
7 Correct 44 ms 2504 KB Output is correct
8 Correct 42 ms 2488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 50 ms 2532 KB Output is correct
6 Correct 53 ms 4528 KB Output is correct
7 Correct 44 ms 2504 KB Output is correct
8 Correct 42 ms 2488 KB Output is correct
9 Correct 3112 ms 17800 KB Output is correct
10 Correct 2998 ms 10792 KB Output is correct
11 Correct 2994 ms 10028 KB Output is correct
12 Correct 3179 ms 18912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2332 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2332 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -