Submission #153929

#TimeUsernameProblemLanguageResultExecution timeMemory
153929popovicirobert철로 (IOI14_rail)C++14
8 / 100
92 ms1280 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; static map <pair <int, int>, int> qry; inline int query(int a, int b) { if(a > b) swap(a, b); if(qry[{a, b}]) { return qry[{a, b}]; } return qry[{a, b}] = getDistance(a, b); } void findLocation(int n, int first, int location[], int stype[]) { location[0] = first; stype[0] = 1; vector < pair <int, int> > arr; int i, l = 0; for(i = 1; i < n; i++) { arr.push_back({query(0, i), i}); } sort(arr.begin(), arr.end()); int r = arr[0].second; location[r] = arr[0].first + first; stype[r] = 2; for(i = 1; i < arr.size(); i++) { int k = arr[i].second; int dst = location[r] - location[l]; if(query(l, k) < dst) { location[k] = location[l] + query(l, k); stype[k] = 2; continue; } if(query(r, k) < dst) { location[k] = location[r] - query(r, k); stype[k] = 1; continue; } if(query(l, k) < query(r, k)) { location[k] = location[l] + query(l, k); stype[k] = 2; r = k; } else { location[k] = location[r] - query(r, k); stype[k] = 1; l = k; } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i = 1; i < arr.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...