#4357
Oxford
Premierul Marii Britanii, Rishi Sunak, a decis să reorganizeze structura administrativă a comitatului Oxfordshire. În Oxfordshire sunt prezente N
orașe numerotate de la 1
la N
, conectate prin M
autostrăzi (drumuri unidirecționale ce conectează două orașe). Rishi a hotărât ca toate orașele cu proprietatea că cetățenii tuturor celorlalte orașe pot ajunge în ele prin intermediul autostrăzilor să devină reședințe. Deoarece numărul de orașe și autostrăzi din Oxfordshire este foarte mare, Rishi vă cere ajutorul în rezolvarea a două probleme cheie.
1. Care sunt indicii orașelor reședință din Oxfordshire.
2. Care este distanța minimă de la fiecare oraș până la cea mai apropiată reședință de acel oraș.
Info-Oltenia 2023, individual 11-12
Problema | Oxford | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 128 MB
/
Stivă 64 MB
|
Id soluție | #54568559 | Utilizator | |
Fișier | oxford.cpp | Dimensiune | 3.55 KB |
Data încărcării | 02 Decembrie 2024, 18:31 | Scor / rezultat | Eroare de compilare |
oxford.cpp: In function 'void findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)': oxford.cpp:19:37: error: parameter declared 'auto' auto dfs1 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp: In lambda function: oxford.cpp:22:54: error: 'dfsRef' was not declared in this scope if (!visited[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp:22:60: error: 'dfsRef' was not declared in this scope if (!visited[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp:22:60: error: redeclaration of '<typeprefixerror>dfsRef' oxford.cpp:22:54: note: previous declaration '<typeprefixerror>dfsRef' if (!visited[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp: In function 'void findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)': oxford.cpp:28:37: error: parameter declared 'auto' auto dfs2 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp: In lambda function: oxford.cpp:31:56: error: 'dfsRef' was not declared in this scope if (!component[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp:31:62: error: 'dfsRef' was not declared in this scope if (!component[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp:31:62: error: redeclaration of '<typeprefixerror>dfsRef' oxford.cpp:31:56: note: previous declaration '<typeprefixerror>dfsRef' if (!component[neighbor]) dfsRef(neighbor, dfsRef); ^ oxford.cpp: In function 'void findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)': oxford.cpp:37:38: error: no match for call to '(findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda0) (int&, findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda0&)' if (!visited[i]) dfs1(i, dfs1); ^ oxford.cpp:19:19: note: candidate is: auto dfs1 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp:19:48: note: findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda0 auto dfs1 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp:19:48: note: candidate expects 1 argument, 2 provided oxford.cpp:46:28: error: no match for call to '(findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda1) (int&, findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda1&)' dfs2(node, dfs2); ^ oxford.cpp:28:19: note: candidate is: auto dfs2 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp:28:48: note: findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)::__lambda1 auto dfs2 = [&](int node, auto &dfsRef) -> void { ^ oxford.cpp:28:48: note: candidate expects 1 argument, 2 provided oxford.cpp: In function 'void calculateDistances(int, const std::vector<std::vector<std::pair<int, int> > >&, const std::vector<int>&)': oxford.cpp:65:79: error: wrong number of template arguments (0, should be 1) priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> pq; ^ 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 oxford.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> ^ oxford.cpp:65:80: error: template argument 3 is invalid priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> pq; ^ oxford.cpp:65:85: error: invalid type in declaration before ';' token priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> pq; ^ oxford.cpp:69:12: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push({0, residence}); ^ oxford.cpp:72:16: error: request for member 'empty' in 'pq', which is of non-class type 'int' while (!pq.empty()) { ^ oxford.cpp:73:14: error: expected unqualified-id before '[' token auto [currentDist, currentNode] = pq.top(); ^ oxford.cpp:74:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^ oxford.cpp:76:13: error: 'currentDist' was not declared in this scope if (currentDist > distances[currentNode]) continue; ^ oxford.cpp:76:37: error: 'currentNode' was not declared in this scope if (currentDist > distances[currentNode]) continue; ^ oxford.cpp:78:39: error: 'currentNode' was not declared in this scope for (const auto &edge : graph[currentNode]) { ^ oxford.cpp:82:17: error: 'currentDist' was not declared in this scope if (currentDist + weight < distances[neighbor]) { ^ oxford.cpp:84:20: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push({distances[neighbor], neighbor}); ^ oxford.cpp: In function 'int main()': oxford.cpp:111:58: error: invalid initialization of reference of type 'const std::vector<std::vector<int> >&' from expression of type 'std::vector<std::vector<std::pair<int, int> > >' findResidences(n, graph, reverseGraph, residences); ^ oxford.cpp:13:6: error: in passing argument 2 of 'void findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)' void findResidences(int n, const vector<vector<int>> &graph, const vector<vector<int>> &reverseGraph, vector<int> &residences) { ^ oxford.cpp:118:58: error: invalid initialization of reference of type 'const std::vector<std::vector<int> >&' from expression of type 'std::vector<std::vector<std::pair<int, int> > >' findResidences(n, graph, reverseGraph, residences); ^ oxford.cpp:13:6: error: in passing argument 2 of 'void findResidences(int, const std::vector<std::vector<int> >&, const std::vector<std::vector<int> >&, std::vector<int>&)' void findResidences(int n, const vector<vector<int>> &graph, const vector<vector<int>> &reverseGraph, vector<int> &residences) { ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Oxford 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ă.