Submission #388589

#TimeUsernameProblemLanguageResultExecution timeMemory
388589alishahali1382Shortcut (IOI16_shortcut)C++14
71 / 100
2072 ms2240 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; #define debug(x) {cerr<<#x<<"="<<x<<"\n";} #define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";} #define pb push_back #define all(x) x.begin(), x.end() const ll INF=10000001000000000ll; const int MAXN=100010; int n, m, k; ll L[MAXN], D[MAXN], X[MAXN], C, ans; ll prefD[MAXN], suffD[MAXN]; ll X1, Y1, X2, Y2; /* void AddRect(ll x, ll y, ll xx, ll yy){ X1=max(X1, x); Y1=max(Y1, y); X2=min(X2, xx); Y2=min(Y2, yy); }*/ bool Check(ll val){ X1=Y1=-INF; X2=Y2=INF; for (int i=1; i<=n; i++) for (int j=1; j<i; j++){ if (D[i]+D[j]+X[i]-X[j]<=val) continue ; ll x=X[j], y=X[i], z=val-C-D[i]-D[j]; X1=max(X1, X[j]+X[i]-val+C+D[i]+D[j]); Y1=max(Y1, X[j]-X[i]-val+C+D[i]+D[j]); X2=min(X2, X[j]+X[i]+val-C-D[i]-D[j]); Y2=min(Y2, X[j]-X[i]+val-C-D[i]-D[j]); // AddRect(x+y-z, x-y-z, x+y+z, x-y+z); } for (int i=1; i<=n; i++){ ll y=X[i]; ll l=max(X1-y, Y1+y), r=min(X2-y, Y2+y); int pos=lower_bound(X+1, X+n+1, l)-X; if (pos<=n && X[pos]<=r) return 1; } return 0; } ll find_shortcut(int _n, vector<int> l, vector<int> d, int _C){ n=_n; C=_C; for (int i=1; i<n; i++) L[i]=l[i-1], X[i+1]=X[i]+L[i]; for (int i=1; i<=n; i++) D[i]=d[i-1]; ll dwn=-1, up=INF; while (up-dwn>1){ ll mid=(dwn+up)>>1; if (Check(mid)) up=mid; else dwn=mid; } return up; }

Compilation message (stderr)

shortcut.cpp: In function 'bool Check(ll)':
shortcut.cpp:32:6: warning: unused variable 'x' [-Wunused-variable]
   32 |   ll x=X[j], y=X[i], z=val-C-D[i]-D[j];
      |      ^
shortcut.cpp:32:14: warning: unused variable 'y' [-Wunused-variable]
   32 |   ll x=X[j], y=X[i], z=val-C-D[i]-D[j];
      |              ^
shortcut.cpp:32:22: warning: unused variable 'z' [-Wunused-variable]
   32 |   ll x=X[j], y=X[i], z=val-C-D[i]-D[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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...