Submission #1030816

#TimeUsernameProblemLanguageResultExecution timeMemory
1030816tolbiRail (IOI14_rail)C++17
30 / 100
3113 ms223148 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; map<pair<int,int>,int> mp; int dist(int a, int b){ if (mp.count({a,b})) return mp[{a,b}]; return mp[{a,b}]=getDistance(a,b); } void findLocation(int N, int first, int location[], int stype[]) { int c = 0, d = 1; for (int i = 2; i < N; i++){ if (dist(c,i)<dist(c,d)) d=i; } vector<int> left; vector<int> right; stype[c]=1,stype[d]=2; location[c]=first,location[d]=first+dist(c,d); for (int i = 0; i < N; i++){ if (i==c || i==d) continue; if (dist(c,i)==dist(c,d)+dist(d,i)){ if (dist(d,i)<dist(c,d)){ location[i]=location[d]-dist(d,i); stype[i]=1; } else left.push_back(i); } else { right.push_back(i); } } sort(left.begin(), left.end(), [&](int a, int b){ return dist(d,a)<dist(d,b); }); sort(right.begin(), right.end(), [&](int a, int b){ return dist(c,a)<dist(c,b); }); if (left.size()){ vector<int> virt; virt.push_back(left[0]); location[virt.back()]=location[d]-dist(d,virt.back()); stype[virt.back()]=1; for (int _ = 1; _ < left.size(); _++){ int i = left[_]; bool boolean=false; int fiC; for (int j = 0; j < virt.size(); j++){ fiC=virt[j]; if (dist(d,i)==dist(d,fiC)+dist(fiC,i)){ boolean=true; break; } } if (boolean){ stype[i]=2; location[i]=location[fiC]+dist(fiC,i); } else { stype[i]=1; location[i]=location[d]-dist(d,i); virt.push_back(i); } } } if (right.size()){ vector<int> virt; virt.push_back(right[0]); location[virt.back()]=location[c]+dist(c,virt.back()); stype[virt.back()]=2; for (int _ = 1; _ < right.size(); _++){ int i = right[_]; bool boolean=false; int fiD; for (int j = 0; j < virt.size(); j++){ fiD=virt[j]; if (dist(c,i)==dist(c,fiD)+dist(fiD,i)){ boolean=true; break; } } if (boolean){ stype[i]=1; location[i]=location[fiD]-dist(fiD,i); } else { stype[i]=2; location[i]=location[c]+dist(c,i); virt.push_back(i); } } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int _ = 1; _ < left.size(); _++){
      |                   ~~^~~~~~~~~~~~~
rail.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |    for (int j = 0; j < virt.size(); j++){
      |                    ~~^~~~~~~~~~~~~
rail.cpp:70:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |   for (int _ = 1; _ < right.size(); _++){
      |                   ~~^~~~~~~~~~~~~~
rail.cpp:74:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |    for (int j = 0; j < virt.size(); j++){
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...