답안 #646167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646167 2022-09-28T20:54:21 Z eNGy Circus (Balkan15_CIRCUS) C++17
0 / 100
13 ms 2508 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);

    for(int x: X){
        L.pb(X[n] - x);
    }

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

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

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

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

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);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -