Submission #395354

#TimeUsernameProblemLanguageResultExecution timeMemory
395354jjang36524Rail (IOI14_rail)C++14
30 / 100
109 ms644 KiB
#include "rail.h" #include <bits/stdc++.h> #define int long long using namespace std; int zero[3001]; int one[3001]; int op; void findLocation(signed N, signed first, signed location[], signed stype[]) { int i; pair<int,int>mi={1LL<<60,1}; for(i=1;i<N;i++) { zero[i]=getDistance(0,i); mi=min(mi,make_pair(zero[i],i)); } stype[0]=1; location[mi.second]=mi.first; stype[mi.second]=2; one[0]=mi.first; vector<pair<int,int>>le; vector<pair<int,int>>re; for(i=0;i<N;i++) { if(i==mi.second||i==0) continue; one[i]=getDistance(mi.second,i); if(zero[i]==one[i]+mi.first) le.push_back({one[i],i}); else re.push_back({zero[i],i}); } sort(le.begin(),le.end()); sort(re.begin(),re.end()); for(i=0;i<le.size();i++) { stype[le[i].second]=1; location[le[i].second]=mi.first-le[i].first; int firstdis=0; int firstp=0; int j; for(j=i-1;j>=0;j--) { if(stype[le[j].second]==1) { firstdis=getDistance(le[i].second,le[j].second); firstp=location[le[j].second]; break; } } if(firstdis==0) { firstdis=getDistance(le[i].second,0); firstp=0; } for(j=0;j<i;j++) { if(stype[le[j].second]==1) { if(firstdis-location[le[j].second]+firstp+one[le[j].second]==one[le[i].second]) { stype[le[i].second]=2; location[le[i].second]=firstp+firstdis; break; } } } } for(i=0;i<re.size();i++) { stype[re[i].second]=2; location[re[i].second]=re[i].first; int firstdis=0; int firstp=0; int j; for(j=i-1;j>=0;j--) { if(stype[re[j].second]==2) { firstdis=getDistance(re[i].second,re[j].second); firstp=location[re[j].second]; break; } } if(firstdis==0) { firstdis=getDistance(re[i].second,mi.second); firstp=location[mi.second]; } for(j=0;j<i;j++) { if(stype[re[j].second]==2) { if(firstdis+location[re[j].second]-firstp+zero[re[j].second]==zero[re[i].second]) { stype[re[i].second]=1; location[re[i].second]=firstp-firstdis; break; } } } } for(i=0;i<N;i++) location[i]+=first; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:35:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(i=0;i<le.size();i++)
      |             ~^~~~~~~~~~
rail.cpp:70:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(i=0;i<re.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...