#4078
Matei, care locuiește in orașul p, vrea să ajungă in orașul q să il viziteze. El are o hartă pe care se află n orașe și m drumuri prin care poate să treacă pentru a ajunge la destinație. Pe hartă apare și durata de timp td pentru fiecare drum, care reprezintă numărul de minute în care este parcurs drumul și to pentru traversarea orașelor (unele orașe sunt mai aglomerate, iar altele nu). Matei vrea să ajungă cat mai rapid la destinație, dar dacă există mai multe trasee de timp minim, il va alege pe acela care trece prin mai multe orașe. Nu vor exista trasee de timp minim cu același număr de orașe. Ajutati-l pe Matei să gasească drumul cerut.
| Problema | Distanta | Operații I/O |
distanta.in/distanta.out
|
|---|---|---|---|
| Limita timp | 0.7 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #61497635 | Utilizator | |
| Fișier | distanta.cpp | Dimensiune | 3.66 KB |
| Data încărcării | 29 Noiembrie 2025, 21:16 | Scor/rezultat | Eroare de compilare |
distanta.cpp: In function 'int main()': distanta.cpp:11:17: error: variable 'std::ifstream fin' has initializer but incomplete type ifstream fin("distanta.in"); ^ distanta.cpp:12:18: error: variable 'std::ofstream fout' has initializer but incomplete type ofstream fout("distanta.out"); ^ distanta.cpp:18:5: error: 'unordered_map' was not declared in this scope unordered_map<string, int> id; ^ distanta.cpp:18:25: error: expected primary-expression before ',' token unordered_map<string, int> id; ^ distanta.cpp:18:27: error: expected primary-expression before 'int' unordered_map<string, int> id; ^ distanta.cpp:18:27: error: expected ';' before 'int' distanta.cpp:21:5: error: 'vector' was not declared in this scope vector<string> name(n + 1); ^ distanta.cpp:21:18: error: expected primary-expression before '>' token vector<string> name(n + 1); ^ distanta.cpp:21:30: error: 'name' was not declared in this scope vector<string> name(n + 1); ^ distanta.cpp:22:12: error: expected primary-expression before 'long' vector<long long> to(n + 1); ^ distanta.cpp:22:12: error: expected ';' before 'long' distanta.cpp:26:27: error: 'to' was not declared in this scope fin >> name[i] >> to[i]; ^ distanta.cpp:27:9: error: 'id' was not declared in this scope id[name[i]] = i; // asociem numele cu indexul ^ distanta.cpp:34:23: error: expected primary-expression before '>>' token vector<vector<Edge>> g(n + 1); ^ distanta.cpp:34:33: error: 'g' was not declared in this scope vector<vector<Edge>> g(n + 1); ^ distanta.cpp:42:17: error: 'id' was not declared in this scope int u = id[a]; ^ distanta.cpp:54:13: error: 'id' was not declared in this scope int p = id[sp]; ^ distanta.cpp:57:27: error: 'LLONG_MAX' was not declared in this scope const long long INF = LLONG_MAX / 4; ^ distanta.cpp:69:37: error: expected primary-expression before '>' token vector<pair<long long, long long>> dist(n + 1, {INF, INF}); ^ distanta.cpp:69:62: error: 'dist' was not declared in this scope vector<pair<long long, long long>> dist(n + 1, {INF, INF}); ^ distanta.cpp:72:12: error: expected primary-expression before 'int' vector<int> parent(n + 1, -1); ^ distanta.cpp:72:12: error: expected ';' before 'int' distanta.cpp:75:5: error: 'priority_queue' was not declared in this scope priority_queue< ^ distanta.cpp:76:46: error: expected primary-expression before ',' token pair<pair<long long, long long>, int>, ^ distanta.cpp:77:52: error: expected primary-expression before '>' token vector<pair<pair<long long, long long>, int>>, ^ distanta.cpp:77:54: error: expected primary-expression before ',' token vector<pair<pair<long long, long long>, int>>, ^ distanta.cpp:78:17: error: wrong number of template arguments (0, should be 1) greater<> ^ In file included from /usr/include/c++/4.8/string:48:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from distanta.cpp:1: /usr/include/c++/4.8/bits/stl_function.h:222:12: error: provided for 'template<class _Tp> struct std::greater' struct greater : public binary_function<_Tp, _Tp, bool> ^ distanta.cpp:79:7: error: 'pq' was not declared in this scope > pq; ^ distanta.cpp:84:16: error: 'to' was not declared in this scope dist[p] = {to[p], -1}; ^ distanta.cpp:89:14: error: expected unqualified-id before '[' token auto [d, u] = pq.top(); ^ distanta.cpp:93:13: error: 'd' was not declared in this scope if (d != dist[u]) continue; ^ distanta.cpp:93:23: error: 'u' was not declared in this scope if (d != dist[u]) continue; ^ distanta.cpp:96:26: error: 'u' was not declared in this scope for (auto &e : g[u]) { ^ distanta.cpp:101:33: error: 'd' was not declared in this scope long long newCost = d.first + e.td + to[v]; ^ distanta.cpp:111:17: error: 'parent' was not declared in this scope parent[v] = u; ^ distanta.cpp:124:12: error: expected primary-expression before 'int' vector<int> path; ^ distanta.cpp:124:12: error: expected ';' before 'int' distanta.cpp:125:34: error: 'parent' was not declared in this scope for (int x = q; x != -1; x = parent[x]) ^ distanta.cpp:126:9: error: 'path' was not declared in this scope path.push_back(x); ^ distanta.cpp:128:13: error: 'path' was not declared in this scope reverse(path.begin(), path.end()); ^ distanta.cpp:128:37: error: 'reverse' was not declared in this scope reverse(path.begin(), path.end()); ^ distanta.cpp:134:18: error: unable to deduce 'auto&&' from 'path' for (int u : path) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Distanta face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.