#4670
gcd_tree
RAU-Gigel și Vlad sunt prieteni buni și le place tot timpul să se provoace unul pe altul. De data aceasta, RAU-Gigel a inventat o problemă interesantă de matematică.
Acesta are un arbore secret cu N
noduri (numerotate de la 1
la N
), în care fiecare nod are asociată o valoare (pe lângă numărul său de ordine din arbore), care este un număr natural și ii spune lui Vlad informații despre unele drumuri din acest arbore. O informație are forma x, y, val
și reprezintă faptul că lanțul din arbore de la nodul x
la nodul y
are cel mai mare divizor comun al valorilor asociate nodurilor acestuia egal cu val
, unde val
este un număr natural nenul.
Vlad știe că RAU-Gigel minte câteodată și s-ar putea ca unele dintre restricțiile date să fie eronate, astfel că vrea să afle întâi folosind informațiile ce le are la îndemână dacă ar putea exista un arbore care să respecte toate restricțiile date de prietenul său.
Pentru că știe ce programator iscusit ești, Vlad ți-ar fi foarte recunoscător daca l-ai putea ajuta cu această problemă prin a scrie un program care să o rezolve cât mai eficient.
RAU-Coder 2024
Problema | gcd_tree | Operații I/O |
gcd_tree.in /gcd_tree.out
|
---|---|---|---|
Limita timp | 2 secunde | Limita memorie |
Total: 256 MB
/
Stivă 64 MB
|
Id soluție | #53987754 | Utilizator | |
Fișier | gcd_tree.cpp | Dimensiune | 2.64 KB |
Data încărcării | 16 Noiembrie 2024, 21:35 | Scor / rezultat | Eroare de compilare |
gcd_tree.cpp: In function 'void unite(int, int)': gcd_tree.cpp:22:13: error: reference to 'rank' is ambiguous if (rank[rootX] > rank[rootY]) { ^ gcd_tree.cpp:9:19: note: candidates are: int rank [100005] int parent[MAXN], rank[MAXN], values[MAXN]; ^ In file included from /usr/include/c++/4.8/bits/move.h:57:0, from /usr/include/c++/4.8/bits/stl_pair.h:59, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from gcd_tree.cpp:1: /usr/include/c++/4.8/type_traits:1243:12: note: template<class> struct std::rank struct rank ^ gcd_tree.cpp:22:27: error: reference to 'rank' is ambiguous if (rank[rootX] > rank[rootY]) { ^ gcd_tree.cpp:9:19: note: candidates are: int rank [100005] int parent[MAXN], rank[MAXN], values[MAXN]; ^ In file included from /usr/include/c++/4.8/bits/move.h:57:0, from /usr/include/c++/4.8/bits/stl_pair.h:59, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from gcd_tree.cpp:1: /usr/include/c++/4.8/type_traits:1243:12: note: template<class> struct std::rank struct rank ^ gcd_tree.cpp:24:20: error: reference to 'rank' is ambiguous } else if (rank[rootX] < rank[rootY]) { ^ gcd_tree.cpp:9:19: note: candidates are: int rank [100005] int parent[MAXN], rank[MAXN], values[MAXN]; ^ In file included from /usr/include/c++/4.8/bits/move.h:57:0, from /usr/include/c++/4.8/bits/stl_pair.h:59, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from gcd_tree.cpp:1: /usr/include/c++/4.8/type_traits:1243:12: note: template<class> struct std::rank struct rank ^ gcd_tree.cpp:24:34: error: reference to 'rank' is ambiguous } else if (rank[rootX] < rank[rootY]) { ^ gcd_tree.cpp:9:19: note: candidates are: int rank [100005] int parent[MAXN], rank[MAXN], values[MAXN]; ^ In file included from /usr/include/c++/4.8/bits/move.h:57:0, from /usr/include/c++/4.8/bits/stl_pair.h:59, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from gcd_tree.cpp:1: /usr/include/c++/4.8/type_traits:1243:12: note: template<class> struct std::rank struct rank ^ gcd_tree.cpp:28:13: error: reference to 'rank' is ambiguous rank[rootX]++; ^ gcd_tree.cpp:9:19: note: candidates are: int rank [100005] int parent[MAXN], rank[MAXN], values[MAXN]; ^ In file included from /usr/include/c++/4.8/bits/move.h:57:0, from /usr/include/c++/4.8/bits/stl_pair.h:59, from /usr/include/c++/4.8/bits/stl_algobase.h:64, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from gcd_tree.cpp:1: /usr/include/c++/4.8/type_traits:1243:12: note: template<class> struct std::rank struct rank ^ gcd_tree.cpp: In function 'bool bfs_check(int)': gcd_tree.cpp:43:20: error: expected unqualified-id before '[' token for (auto& [neighbor, required_gcd] : graph[node]) { ^ gcd_tree.cpp:43:20: error: expected ';' before '[' token gcd_tree.cpp:43:21: error: 'neighbor' was not declared in this scope for (auto& [neighbor, required_gcd] : graph[node]) { ^ gcd_tree.cpp:43:31: error: 'required_gcd' was not declared in this scope for (auto& [neighbor, required_gcd] : graph[node]) { ^ gcd_tree.cpp: In lambda function: gcd_tree.cpp:43:45: error: expected '{' before ':' token for (auto& [neighbor, required_gcd] : graph[node]) { ^ gcd_tree.cpp: In function 'bool bfs_check(int)': gcd_tree.cpp:43:45: error: expected ';' before ':' token gcd_tree.cpp:43:45: error: expected primary-expression before ':' token gcd_tree.cpp:43:45: error: expected ')' before ':' token gcd_tree.cpp:43:45: error: expected primary-expression before ':' token gcd_tree.cpp:43:45: error: expected ';' before ':' token gcd_tree.cpp:105:1: error: expected '}' at end of input } ^ gcd_tree.cpp:42:13: warning: unused variable 'node' [-Wunused-variable] int node = queue[i]; ^ gcd_tree.cpp:105:1: error: expected '}' at end of input } ^ gcd_tree.cpp:105:1: warning: no return statement in function returning non-void [-Wreturn-type]
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema gcd_tree 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ă.