Submission #1021611

#TimeUsernameProblemLanguageResultExecution timeMemory
1021611MarwenElarbiRail (IOI14_rail)C++17
100 / 100
46 ms1104 KiB
#include <bits/stdc++.h> #include "rail.h" using namespace std; #define ll long long #define fi first #define se second #define pb push_back void findLocation(int N, int first, int location[], int stype[]) { vector<pair<int,int>> a; map<int,int> mp; mp[first]=0; location[0]=first; stype[0]=1; for (int i = 1; i < N; ++i) { a.pb({getDistance(0,i),i}); } sort(a.begin(),a.end()); mp[a[0].fi+first]=a[0].se; location[a[0].se]=a[0].fi+first; stype[a[0].se]=2; int l,r; l=0; r=a[0].se; for (int i = 1; i < a.size(); ++i) { int cura=getDistance(l,a[i].se); int curb=getDistance(r,a[i].se); int m=(cura-curb+location[l]+location[r])/2; int test=(mp.find(m)==mp.end()?(m>first ? 1 : 2):stype[mp[m]]); if(test^2){ stype[a[i].se]=2; location[a[i].se]=location[l]+cura; if(location[a[i].se]>location[r]) r=a[i].se; }else{ stype[a[i].se]=1; location[a[i].se]=location[r]-curb; if(location[a[i].se]<location[l]) l=a[i].se; } mp[location[a[i].se]]=a[i].se; } return; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 1; i < a.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...