제출 #525912

#제출 시각아이디문제언어결과실행 시간메모리
525912songcAliens (IOI16_aliens)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct point{ ll x,y; bool operator < (point a)const{ return y>a.y||(y==a.y&&x<a.x); } }; struct line{ ll a,b; int c; ll f(ll x){ return a*x+b; } }; vector<point> V; set<point> S; deque<line> DQ; int N,K,cnt[100100]; ll M,dt[100100]; line getLine(int i,ll lm){ line ret; ll c=V[i+1].y-1; ret.a=-2*c*2; ll over=V[i].x>=V[i+1].y?(V[i].x-V[i+1].y+1):0; ret.b=(c*c+over*over)*2+dt[i]+lm; ret.c=cnt[i]; return ret; } bool chk(line a,line b,line c){ return ((__int128)a.b-c.b)*(c.a-b.a)>=((__int128)b.b-c.b)*(c.a-a.a); } int CHT(ll lm){ DQ.clear(); DQ.push_back(getLine(0,lm)); for(int i=1;i<=N;i++){ while(DQ.size()>=2&&DQ[0].f(V[i].x)>=DQ[1].f(V[i].x)) DQ.pop_front(); dt[i]=DQ.front().f(V[i].x)+2*V[i].x*V[i].x; cnt[i]=DQ.front().c+1; line nx=getLine(i,lm); while(DQ.size()>=2&&chk(DQ[DQ.size()-2],DQ[DQ.size()-1],nx)) DQ.pop_back(); DQ.push_back(nx); } return cnt[N]; } int main(){ int i; ll x,y; scanf("%d %lld %d",&N,&M,&K); for(i=0;i<N;i++){ scanf("%lld %lld",&x,&y); x++,y++; if(x<y) swap(x,y); V.push_back({x,y}); } sort(V.begin(),V.end(),[&](point a,point b){return a.x<b.x||(a.x==b.x&&a.y>b.y);}); for(auto &k:V){ while(!S.empty()&&*S.begin()<k) S.erase(S.begin()); S.insert(k); } V.clear(); V.push_back({0,0}); for(auto &k:S) V.push_back({k.x,k.y}); reverse(V.begin()+1,V.end()); N=V.size()-1; K=min(K,N); ll lo=0,hi=1000000000000ll; ll ans=lo; while(lo<=hi){ ll mid=(lo+hi)/2; if(CHT(2*mid-1)>=K) ans=mid,lo=mid+1; else hi=mid-1; } CHT(2*ans); printf("%lld",(dt[N]-K*2*ans)/2); return 0; }

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

aliens.cpp: In function 'int main()':
aliens.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     scanf("%d %lld %d",&N,&M,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         scanf("%lld %lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccOWvIs2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccI9RTe1.o:aliens.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOWvIs2.o: in function `main':
grader.cpp:(.text.startup+0xf0): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status