(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #117069

#TimeUsernameProblemLanguageResultExecution timeMemory
117069MvCMeetings (IOI18_meetings)C++11
36 / 100
1147 ms239964 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> //#include "meetings.h" #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const ll nmax=1e5+50; const int mod=1e9+7; using namespace std; int n,q,i,j,x,y,lst,t,st[4*nmax]; ll h[nmax],p[5050][5050],s[5050][5050],mx; vector<pair<int,int> >a[nmax],b[nmax]; vector<ll>rs; void upd(int nod,int l,int r,int p,int v) { if(l==r) { st[nod]=max(v,st[nod]); return; } int mid=(l+r)/2; if(p<=mid)upd(2*nod,l,mid,p,v); else upd(2*nod+1,mid+1,r,p,v); st[nod]=max(st[2*nod],st[2*nod+1]); } int qry(int nod,int l,int r,int tl,int tr) { if(tr<l || tl>r)return 0; if(tl<=l && r<=tr)return st[nod]; int mid=(l+r)/2; int v=0; if(tl<=mid)v=qry(2*nod,l,mid,tl,tr); if(tr>mid)v=max(v,qry(2*nod+1,mid+1,r,tl,tr)); return v; } vector<ll> minimum_costs(vector<int>H,vector<int>L,vector<int>R) { n=H.size(),q=L.size(); for(i=1;i<=n;i++)h[i]=H[i-1]; h[n+1]=h[0]=2; for(i=0;i<q;i++) { x=L[i],y=R[i]; x++,y++; if(x>y)swap(x,y); a[y].pb(mkp(x,i)); b[x].pb(mkp(y,i)); } rs.resize(q); if(n<=5000 && q<=5000) { for(i=0;i<q;i++)rs[i]=llinf; for(i=1;i<=n;i++) { mx=0; for(j=i;j<=n;j++) { mx=max(mx,h[j]); p[i][j]=p[i][j-1]+mx; } mx=0; for(j=i-1;j>=1;j--) { mx=max(mx,h[j]); s[i][j]=s[i][j+1]+mx; } } for(i=1;i<=n;i++) { for(j=0;j<a[i].size();j++) { x=a[i][j].fr,y=i; for(t=x;t<=y;t++) { rs[a[i][j].sc]=min(rs[a[i][j].sc],p[t][y]+s[t][x]); } } } return rs; } for(i=1;i<=n;i++) { if(h[i]==2)lst=i; if(lst!=i && h[i+1]==2)upd(1,1,n,lst+1,i-lst); for(j=0;j<a[i].size();j++)rs[a[i][j].sc]=qry(1,1,n,a[i][j].fr,i); } lst=0; for(i=1;i<=n;i++) { if(h[i]==2)lst=i; for(j=0;j<a[i].size();j++)rs[a[i][j].sc]=max(rs[a[i][j].sc],1LL*i-1LL*max(lst,a[i][j].fr-1)); } lst=n+1; for(i=n;i>=1;i--) { if(h[i]==2)lst=i; for(j=0;j<b[i].size();j++)rs[b[i][j].sc]=max(rs[b[i][j].sc],1LL*min(lst,b[i][j].fr+1)-1LL*i); } for(i=1;i<=n;i++) { for(j=0;j<a[i].size();j++) { rs[a[i][j].sc]=rs[a[i][j].sc]+(i-a[i][j].fr+1-rs[a[i][j].sc])*2; } } return rs; }

Compilation message (stderr)

meetings.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
meetings.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:82:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0;j<a[i].size();j++)
            ~^~~~~~~~~~~~
meetings.cpp:97:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<a[i].size();j++)rs[a[i][j].sc]=qry(1,1,n,a[i][j].fr,i);
           ~^~~~~~~~~~~~
meetings.cpp:103:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<a[i].size();j++)rs[a[i][j].sc]=max(rs[a[i][j].sc],1LL*i-1LL*max(lst,a[i][j].fr-1));
           ~^~~~~~~~~~~~
meetings.cpp:109:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<b[i].size();j++)rs[b[i][j].sc]=max(rs[b[i][j].sc],1LL*min(lst,b[i][j].fr+1)-1LL*i);
           ~^~~~~~~~~~~~
meetings.cpp:113:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<a[i].size();j++)
           ~^~~~~~~~~~~~
#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...