Submission #275663

# Submission time Handle Problem Language Result Execution time Memory
275663 2020-08-20T06:58:35 Z 임성재(#5103) Circus (Balkan15_CIRCUS) C++17
40 / 100
3529 ms 524292 KB
#include "circus.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n, m;
int dp[100010];
bool chk[100010];
vector<int> p;
priority_queue<pii, vector<pii>, greater<pii>> pQ;

void init(int N, int M, int P[]){
    n = N;
    m = M;

    for(int i=0; i<n; i++) p.eb(P[i]);

    p.eb(0);
    p.eb(m);
    sort(all(p));

    pQ.em(0, p.size()-1);

    while(pQ.size()) {
        auto x = pQ.top();
        pQ.pop();

        if(chk[x.se]) continue;
        chk[x.se] = true;
        dp[x.se] = x.fi;

        for(int i=0; i<p.size(); i++) {
            if(chk[i]) continue;

            if(abs(p[x.se] - p[i]) >= x.fi) {
                pQ.em(abs(p[x.se] - p[i]), i);
            }
        }
    }

    /*for(int i=0; i<p.size(); i++)
        cout << dp[i] << " ";

    cout << endl;*/
}

int minLength(int D) {
    int ret = m - D;
    for(int i=0; i<p.size(); i++) {
        if(abs(p[i] - D) < dp[i]) continue;
        ret = min(ret, abs(p[i] - D));
    }

    return ret;
}

Compilation message

circus.cpp: In function 'void init(int, int, int*)':
circus.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i=0; i<p.size(); i++) {
      |                      ~^~~~~~~~~
circus.cpp: In function 'int minLength(int)':
circus.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0; i<p.size(); i++) {
      |                  ~^~~~~~~~~
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 1122 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 513 ms 16856 KB Output is correct
6 Correct 509 ms 16848 KB Output is correct
7 Correct 462 ms 16856 KB Output is correct
8 Correct 455 ms 16856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 513 ms 16856 KB Output is correct
6 Correct 509 ms 16848 KB Output is correct
7 Correct 462 ms 16856 KB Output is correct
8 Correct 455 ms 16856 KB Output is correct
9 Incorrect 3529 ms 23328 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1122 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1122 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -