제출 #329954

#제출 시각아이디문제언어결과실행 시간메모리
329954dolphingarlicCircus (Balkan15_CIRCUS)C++14
0 / 100
1099 ms524292 KiB
#include "circus.h" #include <bits/stdc++.h> using namespace std; struct State { int cost, idx, change_cnt; bool dir; // Left = 0 }; bool operator<(State A, State B) { return A.cost > B.cost; } int n, m; vector<int> p, mn; vector<pair<int, int>> to_left, to_right; void init(int N, int M, int P[]) { for (int i = 0; i < N; i++) p.push_back(P[i]); sort(p.begin(), p.end()); p.erase(unique(p.begin(), p.end()), p.end()); n = p.size(), m = M; p.push_back(m); mn = vector<int>(n + 1, INT_MAX); priority_queue<State> pq; pq.push({mn[n] = 0, n, 0, false}); while (pq.size()) { State curr = pq.top(); pq.pop(); if (curr.cost != mn[curr.idx]) continue; for (int i = 0; i < n; i++) { if (curr.change_cnt == 2 && i > curr.idx) break; if (abs(p[curr.idx] - p[i]) >= curr.cost && abs(p[curr.idx] - p[i]) < mn[i]) { bool dir = p[i] > p[curr.idx]; pq.push({mn[i] = abs(p[curr.idx] - p[i]), i, curr.change_cnt + (curr.dir ^ dir), dir}); } } } for (int i = 0; i <= n; i++) if (!to_left.size() || p[i] - mn[i] > to_left.back().first) to_left.push_back({p[i] - mn[i], p[i]}); for (int i = n; ~i; i--) if (!to_right.size() || p[i] + mn[i] < to_right.back().first) to_right.push_back({p[i] + mn[i], p[i]}); reverse(to_right.begin(), to_right.end()); } int minLength(int D) { return min( lower_bound(to_left.begin(), to_left.end(), make_pair(D, 0))->second - D, D - prev(upper_bound(to_right.begin(), to_right.end(), make_pair(D, INT_MAX)))->second ); }

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...