Submission #399919

#TimeUsernameProblemLanguageResultExecution timeMemory
399919ly20Rail (IOI14_rail)C++17
0 / 100
85 ms812 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5123; int diste[MAXN], distd[MAXN]; bool cmp(int a, int b) { return diste[a] < diste[b]; } void findLocation(int n, int first, int location[], int stype[]) { location[0] = first; stype[0] = 1; diste[0] = 0; int mn = -1, ds = 1123456789; for(int i = 1; i < n; i++) { int d = getDistance(0, i); diste[i] = d; if(ds > diste[i]) { mn = i; ds = diste[i]; } } location[mn] = location[0] + ds; vector <int> d, e; for(int i = 1; i < n; i++) { if(i == mn) continue; distd[i] = getDistance(mn, i); if(diste[i] == distd[i] + diste[0]) { if(distd[i] < diste[mn]) { location[i] = location[mn] - distd[i]; stype[i] = 1; } else e.push_back(i); } else d.push_back(i); } sort(e.begin(), e.end(), cmp); sort(d.begin(), d.end(), cmp); int lim = mn; for(int i = 0; i < d.size(); i++) { int cur = e[i]; int dis; if(lim == mn) dis = distd[cur]; else dis = getDistance(lim, cur); int dt = (diste[cur] - dis - diste[lim]) / 2; dt = - dt; int loc = location[lim] - dt; if(dt == 0) { location[cur] = location[0] + diste[cur]; lim = cur; stype[cur] = 2; } else { location[cur] = location[lim] - dt; stype[cur] = 1; } } lim = 0; for(int i = 0; i < e.size(); i++) { int cur = d[i]; int dis; if(lim == 0) dis = diste[cur]; else dis = getDistance(lim, cur); int dt = (distd[cur] - dis - distd[lim]) / 2; dt = -dt; if(dt == 0) { location[cur] = location[mn] - dt; lim = cur; stype[cur] = 1; } else { location[cur] = location[lim] + dt; stype[cur] = 2; } } return; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0; i < d.size(); i++) {
      |                    ~~^~~~~~~~~~
rail.cpp:51:13: warning: unused variable 'loc' [-Wunused-variable]
   51 |         int loc = location[lim] - dt;
      |             ^~~
rail.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i = 0; i < e.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...