Submission #135012

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1350122019-07-23 14:17:09nxteruRail (IOI14_rail)C++14
100 / 100
89 ms928 KiB
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
#define PB push_back
int mad,mic;
vector<P>p;
int h[5005];
set<int>cr,dr;
void findLocation(int n, int f, int l[], int t[]){
l[0]=f,t[0]=1;
cr.insert(f);
for(int i=1;i<n;i++)p.PB(P(getDistance(0,i),i));
sort(p.begin(),p.end());
mad=p[0].S;
l[p[0].S]=f+p[0].F;
h[p[0].S]=p[0].F;
t[p[0].S]=2;
dr.insert(l[p[0].S]);
for(int i=1;i<p.size();i++){
int d=p[i].F,x=p[i].S;
h[x]=d;
int a=getDistance(mic,x),b=getDistance(mad,x);
auto o=cr.upper_bound(l[mic]+a);
o--;
if(b==l[mad]-*o+l[mic]+a-*o)l[x]=l[mic]+a,t[x]=2;
else{
o=dr.upper_bound(l[mad]-b);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<p.size();i++){
              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...