Submission #916399

#TimeUsernameProblemLanguageResultExecution timeMemory
916399biankRail (IOI14_rail)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(),x.end() #define forn(i,n) for(int i=0;i<int(n);i++) #define forsn(i,s,n) for(int i=int(s);i<int(n);i++) #define fst first #define snd second typedef pair<int,int> ii; const int C = 1, D = 2; int getDistance(int i, int j); void findLocation(int n, int first, int loc[], int stype[]) { vector<ii> p(n); forsn(i,1,n) p[i]={getDistance(0,i),i}; sort(ALL(p)); set<ii> Cs, Ds; for(auto [d0,i]:p) { if(Cs.empty()) { loc[i]=first; stype[i]=C; Cs.insert((ii){loc[i],i}); continue; } int minC = Cs.begin()->snd; if(Ds.empty()) { loc[i]=loc[minC]+d0; stype[i]=D; Ds.insert((ii){loc[i],i}); continue; } int maxD = Ds.rbegin()->snd; int distItoC = getDistance(i,minC); int distItoD = getDistance(maxD,i); /*loc[i] = loc[minC] + distItoC; int target = (loc[i] + loc[maxD] - distItoD)/2; auto it = Cs.lower_bound((ii){target,0}); if(it != Cs.end() && loc[i] - it->fst + loc[maxD] - it->fst == distItoD) { stype[i] = D; Ds.insert((ii){loc[i],i}); continue; } loc[i] = loc[maxD] - distItoD; target = (distItoC + loc[i] + loc[minC])/2; it = Ds.lower_bound((ii){target,0}); if(it != Ds.end() && it->fst - loc[i] + it->fst - loc[minC] == distItoC) { stype[i] = C; Cs.insert((ii){loc[i],i}); continue; }*/ loc[i] = loc[minC] + distItoC; if(d0 == loc[i] - loc[0]) { stype[i] = D; Ds.insert((ii){loc[i],i}); } else { loc[i] = loc[maxD] - distItoD; stype[i] = C; Cs.insert((ii){loc[i],i}); } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:19:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |     for(auto [d0,i]:p) {
      |              ^
/usr/bin/ld: /tmp/cccdCwVQ.o: in function `findLocation(int, int, int*, int*)':
rail.cpp:(.text+0x715): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x838): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x848): undefined reference to `getDistance(int, int)'
/usr/bin/ld: /tmp/ccNG7lyQ.o: in function `main':
grader.cpp:(.text.startup+0x2d9): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status