Submission #567405

#TimeUsernameProblemLanguageResultExecution timeMemory
567405gs15120Aliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define lll long long//__int128 #define pii pair<int,int> #define f first #define s second # define PI 3.14159265358979323846 #include <ext/pb_ds/assoc_container.hpp> const ll mod=1000000007,div2=(mod+1)/2,inf=1987654321987654321; using namespace __gnu_pbds; struct chash_key { ll operator()(pii x) const { return (ll)x.first*1000000000 + x.second; } }; //gp_hash_table<pii,int,chash_key> hs[2],p[2]; struct P { int x,y; /*bool operator <(const P &a) const { //if(y!=a.y) //return y<a.y; return y>a.y; }*/ }; struct L { ll a,b; int n; ll sol(ll x) { return a*x+b; } }; struct LI { int x,y; L l={0,inf}; }; int a,b,c,d; int dx[10]={1,0,-1,0,-1,1,-1,1},dy[11]={0,1,0,-1,-1,-1,1,1},sx[4]={0,1,0,1},sy[4]={0,0,1,1}; ll x,y,z,rv,lv; int o[111111]; vector<LI> li; void add(int i,int n,int m,L l) { int h=(n+m)/2; if(l.sol(h)<li[i].l.sol(h)) { swap(l,li[i].l); } L s=li[i].l; if(l.sol(n)<s.sol(n)) { if(!li[i].x) { li[i].x=li.size(); li.push_back({}); } add(li[i].x,n,h,l); } if(l.sol(m)<s.sol(m)) { if(!li[i].y) { li[i].y=li.size(); li.push_back({}); } add(li[i].y,h+1,m,l); } } L get(int i,int n,int m,int k) { if(!i||m<k||n>k) return {0,inf,0}; L l=li[i].l; if(n==m) return l; L s; if(k<=(n+m)/2) s=get(li[i].x,n,(n+m)/2,k); else s=get(li[i].y,(n+m)/2+1,m,k); if(l.sol(k)<s.sol(k)) return l; return s; } int f(ll v) { li.clear(); li.push_back({}); li.push_back({0,0,{0,0,0}}); int ff=0; for(int t=1;t<=a;t++) { L l=get(1,1,100000,t); ff=l.n+1; z=l.sol(t)+(ll)t*t+v; add(1,1,100000,{-2*o[t],z+(ll)o[t]*o[t],l.n+1}); } return ff; } ll take_photos(int n,int m,int k,vector<int> r,vector<int> c) { b=n; a=m; for(int t=1;t<=a;t++) o[t]=t; for(int t=0;t<b;t++) { o[max(r[t],c[t])]=min(min(r[t],c[t]),o[max(r[t],c[t])]); } for(int t=a-1;t;t--) o[t]=min(o[t],o[t+1]); ll s=0,e=0;//100000000000; int x=0,y=a+1; for(;s<=e;) { ll h=(s+e)/2; int ff=f(h); if(ff==k) { //printf("@@%d %lld %lld %lld %lld\n",ff,z-k*h,h,s,e); return z-k*h; } if(ff>k) { if(x<ff) x=ff,lv=z-ff*h; s=h+1; } else { if(y>ff) y=ff,rv=z-ff*h; e=h-1; } //printf("%d %lld %lld %lld %lld\n",ff,z-k*h,h,s,e); } return rv+(lv-rv)/(y-x)*(y-k); } int main() { int a=2,b=6,k=2; vector<int> v1={1,4},v2={4,1}; printf("%lld",take_photos(a,b,k,v1,v2)); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccIpWmXW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctCvz5W.o:aliens.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status