#1032
Compresie
Se consideră un text memorat într-o matrice M
, definită prin coordonatele colţului stânga sus (x1,y1)
şi coordonatele colţului dreapta jos (x2,y2)
.
Prin aplicarea unui algoritm de compresie, matricei M
i se asociază un şir de caractere, notat C
M
. Şirul de caractere C
M
este construit prin aplicarea următoarelor reguli:
M
are o singură linie şi o singură coloană atunci C
M
conţine numai caracterul memorat în matrice;M
se comprimă şi C
M
este şirul kc
, unde k
reprezintă numărul de caractere din matrice, iar c
caracterul memorat;4
submatrice A
, B
, C
, D
după cum este ilustrat în figura alăturată, unde coordonatele colţului stânga sus ale submatricei A
sunt (x1,y1)
, iar coordonatele colţului dreapta jos sunt ((x2+x1)/2,(y2+y1)/2)
;C
M
este şirul *C
A
C
B
C
C
C
D
unde C
A
, C
B
, C
C
, C
D
sunt şirurile de caractere obţinute, în ordine, prin compresia matricelor A
, B
, C
, D
utilizând acelaşi algoritm;C
M
este şirul *C
A
C
B
unde A
, B
, C
A
, C
B
au semnificaţia descrisă la punctul 3.;C
M
este şirul *C
A
C
C
unde A
, C
, C
A
, C
C
au semnificaţia descrisă la punctul 3.;Dat fiind şirul de caractere C
M
ce se obţine în urma aplicării algoritmului de compresie asupra unei matrice M de dimensiune NxN
să se determine:
OJI 2012, clasa a X-a
Problema | Compresie | Operații I/O |
compresie.in /compresie.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 4 MB
/
Stivă 3 MB
|
Id soluție | #16692539 | Utilizator | |
Fișier | compresie.cpp | Dimensiune | 1.62 KB |
Data încărcării | 16 Septembrie 2019, 19:40 | Scor / rezultat | Eroare de compilare |
compresie.cpp:7:27: error: 'long long int index' redeclared as different kind of symbol long long nrCompresii,dim,index; ^ In file included from /usr/include/c++/4.8/cstring:42:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:48, from compresie.cpp:1: /usr/include/string.h:482:1: error: previous declaration of 'const char* index(const char*, int)' index (const char *__s, int __c) __THROW ^ compresie.cpp: In function 'void matrice(int, int, int, int)': compresie.cpp:26:13: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') if(s[index]=='*'){ ^ compresie.cpp:26:13: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:27:15: error: no pre-increment operator for type ++index; ^ compresie.cpp:35:18: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') else if(s[index]>='a' && s[index]<='z'){ ^ compresie.cpp:35:18: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:35:35: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') else if(s[index]>='a' && s[index]<='z'){ ^ compresie.cpp:35:35: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:36:26: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') a[i1][j1] = s[index]; ^ compresie.cpp:36:26: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:37:15: error: no pre-increment operator for type ++index; ^ compresie.cpp:43:20: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') while(s[index]>='0' && s[index]<='9'){++index;} ^ compresie.cpp:43:20: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:43:37: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') while(s[index]>='0' && s[index]<='9'){++index;} ^ compresie.cpp:43:37: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:43:53: error: no pre-increment operator for type while(s[index]>='0' && s[index]<='9'){++index;} ^ compresie.cpp:46:32: error: no match for 'operator[]' (operand types are 'std::string {aka std::basic_string<char>}' and '<unresolved overloaded function type>') a[x][y] = s[index]; ^ compresie.cpp:46:32: note: candidates are: In file included from /usr/include/c++/4.8/string:52: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/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from compresie.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:826:7: note: std::basic_string<_CharT, _Traits, _Alloc>::const_reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[] (size_type __pos) const ^ /usr/include/c++/4.8/bits/basic_string.h:826:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/basic_string.h:843:7: note: std::basic_string<_CharT, _Traits, _Alloc>::reference std::basic_string<_CharT, _Traits, _Alloc>::operator[](std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int] operator[](size_type __pos) ^ /usr/include/c++/4.8/bits/basic_string.h:843:7: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_string<char>::size_type {aka unsigned int}' compresie.cpp:49:15: error: no pre-increment operator for type ++index; ^ compresie.cpp:24:13: warning: unused variable 'nr' [-Wunused-variable] int x,y,nr; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Compresie 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ă.