제출 #396036

#제출 시각아이디문제언어결과실행 시간메모리
396036jjang36524철로 (IOI14_rail)C++14
100 / 100
126 ms772 KiB
#include "rail.h" #include <bits/stdc++.h> #define int long long using namespace std; int zero[5001]; int one[5001]; 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; le.push_back({one[0],0}); 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; if(one[le[i].second]<=one[0]) { continue; } 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; } } 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; }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:36:18: 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]
   36 |         for(i=0;i<le.size();i++)
      |                 ~^~~~~~~~~~
rail.cpp:71:18: 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]
   71 |         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...