# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275818 | 2020-08-20T07:52:55 Z | 임성재(#5103) | Circus (Balkan15_CIRCUS) | C++17 | 64 ms | 11556 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; typedef pair<int,pii> piii; const int inf = 1e9; const ll INF = 1e18; int n, m; int dp[100010]; bool chk[100010]; set<int> s; vector<int> p; priority_queue<piii, vector<piii>, greater<piii>> pQ; int close(int x) { int md = dp[x]; int ret = m+1, y = -1; auto it = s.lower_bound(x + md); if(it != s.end()) { if(*it - x < ret) { ret = *it - x; y = *it; } } it = s.upper_bound(x - md); if(it != s.begin()) { if(x - *prev(it) < ret) { ret = x - *prev(it); y = *prev(it); } } return y; } void init(int N, int M, int P[]){ n = N; m = M; for(int i=0; i<n; i++) p.eb(P[i]); for(int i=0; i<p.size(); i++) s.insert(p[i]); pQ.em(0, mp(m, m)); while(pQ.size()) { auto x = pQ.top(); pQ.pop(); //cout << x.fi << " " << x.se.fi << " " << x.se.se << endl; if(chk[x.se.fi]) continue; chk[x.se.fi] = true; dp[x.se.fi] = x.fi; s.erase(x.se.fi); /*int c = close(x.se.fi); if(c != -1) pQ.em(abs(c - x.se.fi), mp(c, x.se.fi)); c = close(x.se.se); if(c != -1) pQ.em(abs(c - x.se.se), mp(c, x.se.se));*/ int c1 = -1, c2 = -1; if(s.lower_bound(x.se.fi + dp[x.se.fi]) != s.end()) c2 = *s.lower_bound(x.se.fi + dp[x.se.fi]); for(auto i : s) { if(i <= x.se.fi - dp[x.se.fi]) c1 = i; } if(c1 != -1) pQ.em(x.se.fi - c1, mp(c1, x.se.fi)); if(c2 != -1) pQ.em(c2 - x.se.fi, mp(c2, x.se.fi)); c1 = -1, c2 = -1; for(auto i : s) { if(i <= x.se.se - dp[x.se.se]) c1 = i; if(i >= x.se.se + dp[x.se.se]) { c2 = i; break; } } if(c1 != -1) pQ.em(x.se.se - c1, mp(c1, x.se.se)); if(c2 != -1) pQ.em(c2 - x.se.se, mp(c2, x.se.se)); } } int minLength(int D) { int ret = m - D; for(int i=0; i<p.size(); i++) { if(abs(p[i] - D) < dp[p[i]]) continue; ret = min(ret, abs(p[i] - D)); } return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 64 ms | 11556 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | Incorrect | 49 ms | 512 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | Incorrect | 49 ms | 512 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 64 ms | 11556 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 64 ms | 11556 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |