Submission #113364

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1133642019-05-25 08:34:41TadijaSebezShortcut (IOI16_shortcut)C++11
100 / 100
1291 ms32504 KiB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1000050;
const ll inf=5e18;
int n,d[N],c,q[N],ql,qr;
ll x[N];
bool Check(ll k)
{
ll mx=-inf,mn=inf;
ll ls=-inf,rs=inf,ld=-inf,rd=inf;
ql=1;qr=0;
for(int i=1;i<=n;i++)
{
for(;ql<=qr && x[q[ql]]-d[q[ql]]<x[i]+d[i]-k;ql++) mx=max(mx,x[q[ql]]+d[q[ql]]),mn=min(mn,x[q[ql]]-d[q[ql]]);
ls=max(ls,mx+x[i]+d[i]-k+c);
rs=min(rs,mn+x[i]-d[i]+k-c);
ld=max(ld,mx-x[i]+d[i]-k+c);
rd=min(rd,mn-x[i]-d[i]+k-c);
for(;ql<=qr && x[q[qr]]-d[q[qr]]>=x[i]-d[i];qr--);
q[++qr]=i;
}
int l1=n+1,r1=n+1,l2=0,r2=0;
for(int i=1;i<=n;i++)
{
for(;l1>=2 && x[i]+x[l1-1]>=ls;l1--);
for(;r1>=1 && x[i]+x[r1]>rs;r1--);
for(;l2<=n && x[i]-x[l2]>rd;l2++);
for(;r2<n && x[i]-x[r2+1]>=ld;r2++);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:40:32: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  ll lo=0,hi=2*mxd+x[n],mi=lo+hi+1>>1;
                           ~~~~~^~
shortcut.cpp:41:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  for(;lo<hi;mi=lo+hi+1>>1)
                ~~~~~^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...