제출 #395334

#제출 시각아이디문제언어결과실행 시간메모리
395334jjang36524철로 (IOI14_rail)C++14
30 / 100
242 ms720 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; le.push_back({mi.first,0}); re.push_back({mi.first,mi.second}); 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=0;j<i;j++) { if(stype[le[j].second]==1) { firstdis=getDistance(le[i].second,le[j].second); firstp=one[le[j].second]; } } for(j=0;j<i;j++) { if(stype[le[j].second]==1) { if(firstdis+one[le[j].second]-firstp+one[le[j].second]==one[le[i].second]) { stype[le[i].second]=2; location[le[i].second]=mi.first-(one[le[j].second]-(firstdis+one[le[j].second]-firstp)); } } } } 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=0;j<i;j++) { if(stype[re[j].second]==2) { firstdis=getDistance(re[i].second,re[j].second); firstp=zero[re[j].second]; } } for(j=0;j<i;j++) { if(stype[re[j].second]==2) { if(firstdis+zero[re[j].second]-firstp+zero[re[j].second]==zero[re[i].second]) { stype[re[i].second]=1; location[re[i].second]=zero[re[j].second]-(firstdis+zero[re[j].second]-firstp); } } } } for(i=0;i<N;i++) location[i]+=first; }

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

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