Submission #612705

#TimeUsernameProblemLanguageResultExecution timeMemory
612705moreteSky Walking (IOI19_walk)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "walk.h" #include<iostream> #include<vector> #include<map> #include<set> #include<tuple> #include<algorithm> using namespace std; #define pb push_back #define snd second #define fst first typedef long long int ll; const ll INF = 9e18; long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) { int n, m; map<ll, ll> dst; // altura, custo vertical, barra horizontal map<ll, vector<ll>> com, fim; n = x.size(); m = l.size(); for (int i = 0; i < m; i++){ // altura tem que bater pelo enunciado com[x[l[i]]].push_back(y[i]); fim[x[r[i]]].push_back(y[i]); // sei onde começa e onde acaba } // tomar cuidado com inicio e fim na mesma altura na mesma barra ll ans = INF; //INF dst[0] = 0; // altura zero no inicio fim[x[0]].pb(0); // depois não é mais válido for (int i = 0; i < n; i++){ set<int> stay; for (auto e : com[x[i]]){ if (dst.count(e)) stay.insert(e); // não apaga essa altura, pode manter o mesmo valor else{ auto it = dst.lower_bound(e); auto dit = it; if (dit != dst.begin()) // se existe dit--; ll val = INF; //INF if ((it != dst.end())){ // caminho válido val = min(val, (*it).snd + abs((*it).fst - e)); } if ((dit != dst.end())){ // caminho válido val = min(val, (*dit).snd + abs((*dit).fst - e)); } dst[e] = val; } } if (i == n - 1){ for (auto e : dst) ans = min(ans, e.fst + e.snd); } for (auto e : fim[x[i]]) if (!stay.count(e)) dst.erase(e); // cout<<i<<" "<<x[i]<<endl; // for (auto e : dst) // cout<<e.fst<<" -- "<<e.snd<<endl; // cout<<"--------"<<endl<<endl; } return ans + (ll)((ll)x[n - 1] - (ll)x[0]); } signed main(){ int n, m; assert(2 == scanf("%d%d", &n, &m)); vector<int> x(n), h(n); for (int i = 0; i < n; i++) assert(2 == scanf("%d%d", &x[i], &h[i])); vector<int> l(m), r(m), y(m); for (int i = 0; i < m; i++) assert(3 == scanf("%d%d%d", &l[i], &r[i], &y[i])); int s, g; assert(2 == scanf("%d%d", &s, &g)); fclose(stdin); long long result = min_distance(x, h, l, r, y, s, g); printf("%lld\n", result); fclose(stdout); return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccDax4UD.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccpFTJWF.o:walk.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status