#1729
Dorel
Îl cunoașteți pe Dorel cel ”priceput” la toate. Acesta și-a propus să “strice” armonia unui șir S
format din N
caractere litere mici ale alfabetului englez, S=(S[1],S[2],…,S[N])
.
El alege la întâmplare un caracter din șir, caracter aflat pe poziția k
(1≤k≤N
) și caută în stânga lui k
primul caracter mai mare sau egal cu S[k]
, fie acesta aflat pe poziția i
, S[k]≤S[i]
. Dacă acesta nu există, i=1
. Această alegere nu este suficientă. Dorel caută în dreapta lui k
primul caracter mai mic sau egal cu S[k]
, fie acesta pe poziția j
, S[j]≤S[k]
. Dacă acesta nu există, j=N
. Extrage din șirul S
subșirul astfel delimitat. Ca urmare a alegerii făcute, Dorel obține două subșiruri:
X=(S[1],S[2],…,S[i-1],S[j+1],S[j+2],…,S[N])
Y=(S[i],S[i+1],…,S[j])
Cunoscând șirul S
, ajutați-l pe Dorel să răspundă la Q
întrebări de forma:
k
din șirul S
să se determine lungimea maximă a unei subsecvențe palindromice comune șirurilor X
și Y
.Lot Juniori Magurele, 2016
Problema | Dorel | Operații I/O |
dorel.in /dorel.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 128 MB
/
Stivă 8 MB
|
Id soluție | #2756733 | Utilizator | |
Fișier | dorel.cpp | Dimensiune | 3.76 KB |
Data încărcării | 23 August 2016, 15:34 | Scor / rezultat | Eroare de compilare |
In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>': /usr/include/c++/4.8/bits/hashtable_policy.h:1402:10: required from 'struct std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::equal_to<std::pair<int, int> >, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >' /usr/include/c++/4.8/bits/hashtable.h:174:11: required from 'class std::_Hashtable<std::pair<int, int>, std::pair<int, int>, std::allocator<std::pair<int, int> >, std::__detail::_Identity, std::equal_to<std::pair<int, int> >, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >' /usr/include/c++/4.8/bits/unordered_set.h:96:18: required from 'class std::unordered_set<std::pair<int, int> >' dorel.cpp:18:23: required from here /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^ In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^ In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h:1082:53: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' using __ebo_h1 = _Hashtable_ebo_helper<1, _H1>; ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^ In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h:1082:53: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' using __ebo_h1 = _Hashtable_ebo_helper<1, _H1>; ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^ dorel.cpp: In constructor 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type = unsigned int; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::hasher = std::hash<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]': dorel.cpp:18:23: error: invalid use of incomplete type 'std::unordered_set<std::pair<int, int> >::hasher {aka struct std::hash<std::pair<int, int> >}' unordered_set< Pair > ap; ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'std::unordered_set<std::pair<int, int> >::hasher {aka struct std::hash<std::pair<int, int> >}' struct hash; ^ dorel.cpp:18:23: note: when instantiating default argument for call to std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type = unsigned int; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::hasher = std::hash<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >] unordered_set< Pair > ap; ^ In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_M_hash_code(const _Key&) const [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code = unsigned int]': /usr/include/c++/4.8/bits/hashtable.h:1023:50: required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::iterator std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::find(const key_type&) [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::iterator = std::__detail::_Node_iterator<std::pair<int, int>, true, true>; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::key_type = std::pair<int, int>]' /usr/include/c++/4.8/bits/unordered_set.h:517:29: required from 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::iterator std::unordered_set<_Value, _Hash, _Pred, _Alloc>::find(const key_type&) [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::iterator = std::__detail::_Node_iterator<std::pair<int, int>, true, true>; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::key_type = std::pair<int, int>]' dorel.cpp:86:55: required from here /usr/include/c++/4.8/bits/hashtable_policy.h:1103:22: error: no match for call to '(const std::hash<std::pair<int, int> >) (const std::pair<int, int>&)' { return _M_h1()(__k); } ^ /usr/include/c++/4.8/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_Hash_code_base(const _ExtractKey&, const _H1&, const _H2&, const std::__detail::_Default_ranged_hash&) [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing]': /usr/include/c++/4.8/bits/hashtable_policy.h:1463:65: required from 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::_Hashtable_base(const _ExtractKey&, const _H1&, const _H2&, const _Hash&, const _Equal&) [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' /usr/include/c++/4.8/bits/hashtable.h:828:24: required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable(std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::size_type, const _H1&, const _H2&, const _Hash&, const _Equal&, const _ExtractKey&, const allocator_type&) [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::size_type = unsigned int; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::allocator_type = std::allocator<std::pair<int, int> >]' /usr/include/c++/4.8/bits/hashtable.h:397:26: required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable(std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::size_type, const _H1&, const key_equal&, const allocator_type&) [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _H1 = std::hash<std::pair<int, int> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::size_type = unsigned int; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::key_equal = std::equal_to<std::pair<int, int> >; std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::allocator_type = std::allocator<std::pair<int, int> >]' /usr/include/c++/4.8/bits/unordered_set.h:136:35: required from 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type = unsigned int; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::hasher = std::hash<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::key_equal = std::equal_to<std::pair<int, int> >; std::unordered_set<_Value, _Hash, _Pred, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' dorel.cpp:18:23: required from here /usr/include/c++/4.8/bits/hashtable_policy.h:1099:63: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' : __ebo_extract_key(__ex), __ebo_h1(__h1), __ebo_h2(__h2) { } ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^ In file included from /usr/include/c++/4.8/bits/hashtable.h:35:0, from /usr/include/c++/4.8/unordered_set:47, from dorel.cpp:4: /usr/include/c++/4.8/bits/hashtable_policy.h:1099:63: error: invalid use of incomplete type 'struct std::hash<std::pair<int, int> >' : __ebo_extract_key(__ex), __ebo_h1(__h1), __ebo_h2(__h2) { } ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:3033:0, from /usr/include/c++/4.8/string:52, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from dorel.cpp:1: /usr/include/c++/4.8/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<std::pair<int, int> >' struct hash; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Dorel 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ă.