Submission #275241

# Submission time Handle Problem Language Result Execution time Memory
275241 2020-08-20T05:04:07 Z 임성재(#5103) Circus (Balkan15_CIRCUS) C++17
0 / 100
625 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];
vector<int> p;
vector<pii> e;

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));
    p.erase(unique(all(p)), p.end());

    for(int i = 0; i < p.size(); i++) {
        for(int j = i; j < p.size(); j++) {
            e.eb(i, j);
        }
    }

    sort(all(e), [&](pii i, pii j) {
        if(p[i.se] - p[i.fi] == p[j.se] - p[j.fi]) return i.se > j.se;
        return p[i.se] - p[i.fi] < p[j.se] - p[j.fi];
    });

    for(int i=0; i<p.size(); i++)
        dp[i] = m+1;

    for(auto i : e) {
        if(p[i.se] == m) dp[i.fi] = min(dp[i.fi], m - p[i.fi]);
        else {
            dp[i.fi] = min(dp[i.fi], max(p[i.se] - p[i.fi], dp[i.se]));
            dp[i.se] = min(dp[i.se], max(p[i.se] - p[i.fi], dp[i.fi]));
        }
    }

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

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:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0; i < p.size(); i++) {
      |                    ~~^~~~~~~~~~
circus.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int j = i; j < p.size(); j++) {
      |                        ~~^~~~~~~~~~
circus.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0; i<p.size(); i++)
      |                  ~^~~~~~~~~
circus.cpp: In function 'int minLength(int)':
circus.cpp:64:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     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 625 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 625 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 625 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -