제출 #960620

#제출 시각아이디문제언어결과실행 시간메모리
960620lucriAliens (IOI16_aliens)C++17
60 / 100
2051 ms7880 KiB
#pragma once #include <bits/stdc++.h> struct intervale{long long b,e;}a[100010]; long long ans[100010][2],bi,ei; struct slope{long long a,b;}b[100010]; void elimina(long long x) { while(bi<ei) { if(b[bi].a*x+b[bi].b>b[bi+1].a*x+b[bi+1].b) ++bi; else break; } } void adauga(long long an,long long bn) { while(bi<ei) { ///a*x+b=c*x+d ///x=(d-b)/(a-c) if((b[ei-1].a-b[ei].a)*(bn-b[ei].b)<(b[ei].a-an)*(b[ei].b-b[ei-1].b)) --ei; else break; } b[++ei]={an,bn}; } bool comp(intervale a,intervale b) { if(a.b!=b.b)return a.b<b.b; return a.e>b.e; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for(long long i=0;i<n;++i) a[i+1]={std::min(r[i],c[i])+1,std::max(r[i],c[i])+1}; std::sort(a+1,a+n+1,comp); long long poz=1,l2=0; for(long long i=1;i<=n;++i) if(a[i].e>l2) { l2=a[i].e; a[poz++]=a[i]; } n=poz-1; for(int i=1;i<=n;++i) ans[i][0]=1000000000000000000; for(int j=1;j<=k;++j) { bi=0,ei=-1; adauga(2-2*a[1].b,a[1].b*a[1].b-2*a[1].b+ans[0][0]); for(int i=1;i<=n;++i) { /*for(int ii=1;ii<=i;++ii) ans[i][1]=std::min(ans[i][1],ans[ii-1][0]+(a[i].e-a[ii].b+1)*(a[i].e-a[ii].b+1)-std::max(1LL*0,(a[ii-1].e-a[ii].b+1))*(a[ii-1].e-a[ii].b+1));*/ ///ans[ii-1][0]+(a[i].e-a[ii].b+1)*(a[i].e-a[ii].b+1)-std::max(1LL*0,(a[ii-1].e-a[ii].b+1))*(a[ii-1].e-a[ii].b+1) ///(a[i].e-a[ii].b+1)*(a[i].e-a[ii].b+1) ///a[ii].b^2+1-2*a[ii].b-2*a[i].e*a[ii].b+2*a[i].e+a[i].e^2 ///C=a[ii].b^2-2*a[ii].b+ans[ii-1][0]-std::max(1LL*0,(a[ii-1].e-a[ii].b+1))*(a[ii-1].e-a[ii].b+1) ///C+(2-2*a[ii].b)*a[i].e+a[i].e^2+1 elimina(a[i].e); ans[i][1]=b[bi].a*a[i].e+b[bi].b; ans[i][1]+=a[i].e*a[i].e+1; adauga(2-2*a[i+1].b,a[i+1].b*a[i+1].b-2*a[i+1].b+ans[i][0]-std::max(1LL*0,(a[i].e-a[i+1].b+1))*(a[i].e-a[i+1].b+1)); } for(int i=1;i<=n;++i) { ans[i][0]=ans[i][1]; ans[i][1]=0; } } return ans[n][0]; }

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

aliens.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...