제출 #679612

#제출 시각아이디문제언어결과실행 시간메모리
679612alirezasamimi100Aliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; using ll = long long int; using pll = pair<ll, ll>; using ld = long double; using pld = pair<ld, int>; using pdd = pair<ld, ld>; #define pb push_back #define F first #define S second const ld eps = 1e-19; const int N = 1e5 + 10;   vector<pll> vec; pld dp[N]; int n; struct CHT{ const ld INF=1e18; pair<ld, pair<pdd,int>> A[N]; int L, R; CHT(){ L=R=0; } inline ld Intersect(pdd a, pdd b){ if (a.first==b.first) return (a.second>=b.second?-INF:INF); return (a.second-b.second)/(b.first-a.first); } inline void Add(pair<pdd,int> X){ while (L<R && Intersect(A[R-1].second.first, X.first)<=A[R-1].first) R--; if (L==R) A[R++]={-INF, X}; else A[R]={Intersect(A[R-1].second.first, X.first), X}, R++; } inline pld GetMin(ld x){ while (L+1<R && A[L+1].first<=x) L++; return {A[L].second.first.first*x + A[L].second.first.second,A[L].second.second}; } } cht; void solve(ld cs){ cht.L=cht.R=0; for(int i=1; i<=n; i++){ ld x=vec[i-1].S-vec[i].F+1; if(x>=0) x*=x; else x=0; cht.Add({{(ld)-vec[i].F,cs+dp[i-1].F+vec[i].F*vec[i].F-x},dp[i-1].S+1}); dp[i]=cht.GetMin(2*(vec[i].S+1)); dp[i].F+=(vec[i].S+1)*(vec[i].S+1); } } ll take_photos(int n, int m, int k, vector<int> R, vector<int> C) { vector<pll> tp={{-1,-1}}; for(int i=0; i<n; i++){ if(R[i]>C[i]) swap(R[i],C[i]); tp.pb({R[i],C[i]}); } sort(tp.begin(),tp.end()); for(auto [x,y] : tp){ while(!vec.empty() && vec.back().F==x) vec.pop_back(); if(vec.empty() || vec.back().S<y) vec.pb({x,y}); } n=(int)vec.size()-1; ::n=n; ll l=0,r=1e13; while(r-l>1){ ll m=(l+r)/2; solve(m); if(dp[n].S<=k) r=m; else l=m; } solve(l); int x1 = dp[n].S; ll y1 = dp[n].F - l * x1; solve(r); int x2 = dp[n].S; ll y2 = dp[n].F - r * x2; if(x2 == k) return y2; return y1 + (x1 - k) * l; }

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

aliens.cpp:14:5: error: extended character   is not valid in an identifier
   14 |      
      |     ^
aliens.cpp:14:5: error: '\U000000a0' does not name a type
   14 |      
      |     ^
aliens.cpp: In function 'void solve(ld)':
aliens.cpp:42:14: error: 'vec' was not declared in this scope
   42 |         ld x=vec[i-1].S-vec[i].F+1;
      |              ^~~
aliens.cpp:45:79: error: cannot convert '<brace-enclosed initializer list>' to 'std::pair<std::pair<long double, long double>, int>'
   45 |         cht.Add({{(ld)-vec[i].F,cs+dp[i-1].F+vec[i].F*vec[i].F-x},dp[i-1].S+1});
      |                                                                               ^
aliens.cpp:29:37: note:   initializing argument 1 of 'void CHT::Add(std::pair<std::pair<long double, long double>, int>)'
   29 |       inline void Add(pair<pdd,int> X){
      |                       ~~~~~~~~~~~~~~^
aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:58:16: error: 'vec' was not declared in this scope
   58 |         while(!vec.empty() && vec.back().F==x) vec.pop_back();
      |                ^~~
aliens.cpp:59:12: error: 'vec' was not declared in this scope
   59 |         if(vec.empty() || vec.back().S<y) vec.pb({x,y});
      |            ^~~
aliens.cpp:61:14: error: 'vec' was not declared in this scope
   61 |       n=(int)vec.size()-1;
      |              ^~~