#4490
Gray
Dată o secvență de n
biți reprezentând un cod binar, să se determine secvența asociată din codul Gray(n)
, apoi dat un șir de n
biți reprezentând o secvență a codului Gray(n)
, să se determine codul binar asociat.
Folclorul informatic
Problema | Gray | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54012037 | Utilizator | |
Fișier | gray.cpp | Dimensiune | 3.34 KB |
Data încărcării | 17 Noiembrie 2024, 20:31 | Scor / rezultat | Eroare de compilare |
gray.cpp:49:11: error: conflicting declaration 'long long int n' long long n,m,a[55][55]; ^ gray.cpp:7:5: error: 'n' has a previous declaration as 'int n' int n; ^ gray.cpp:49:13: error: conflicting declaration 'long long int m' long long n,m,a[55][55]; ^ gray.cpp:8:5: error: 'm' has a previous declaration as 'int m [102][102]' int m[102][102] = {{0}}; ^ gray.cpp: In function 'int main()': gray.cpp:51:5: error: redefinition of 'int main()' int main() ^ gray.cpp:11:5: error: 'int main()' previously defined here int main() ^ gray.cpp:54:8: error: cannot bind 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' fin>>n>>m; ^ In file included from /usr/include/c++/4.8/iostream:40:0, from gray.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [102][102]]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ gray.cpp:59:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] for(int j=2;j<=m;j++) ^ gray.cpp:62:17: error: invalid types 'long long int [55][int [102][102]]' for array subscript fout<<a[n][m]<<endl; ^ gray.cpp: At global scope: gray.cpp:75:13: error: redefinition of 'std::ifstream fin' ifstream fin("cladire3.in"); ^ gray.cpp:46:10: error: 'std::ifstream fin' previously declared here ifstream fin("pacman_xi.in"); ^ gray.cpp:76:14: error: redefinition of 'std::ofstream fout' ofstream fout("cladire3.out"); ^ gray.cpp:47:10: error: 'std::ofstream fout' previously declared here ofstream fout("pacman_xi.out"); ^ gray.cpp:78:5: error: redefinition of 'int n' int n, m, c[202][202], s[202][202]; ^ gray.cpp:7:5: error: 'int n' previously declared here int n; ^ gray.cpp:78:8: error: conflicting declaration 'int m' int n, m, c[202][202], s[202][202]; ^ gray.cpp:8:5: error: 'm' has a previous declaration as 'int m [102][102]' int m[102][102] = {{0}}; ^ gray.cpp:78:34: error: conflicting declaration 'int s [202][202]' int n, m, c[202][202], s[202][202]; ^ gray.cpp:9:5: error: 's' has a previous declaration as 'int s [102][102]' int s[102][102] = {{0}}; ^ gray.cpp: In function 'int main()': gray.cpp:80:5: error: redefinition of 'int main()' int main() ^ gray.cpp:11:5: error: 'int main()' previously defined here int main() ^ gray.cpp:83:9: error: cannot bind 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' fin >> n >> m; ^ In file included from /usr/include/c++/4.8/iostream:40:0, from gray.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [102][102]]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ gray.cpp:85:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] for (int j = 1; j <= m; j++) ^ gray.cpp:93:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] for (int j = 1; j <= m; j++) ^ gray.cpp:99:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] for (int j = 1; j <= m; j++) ^ gray.cpp:102:19: error: invalid types 'int [102][int [102][102]]' for array subscript fout << s[1][m]; ^ gray.cpp: At global scope: gray.cpp:117:13: error: redefinition of 'std::ifstream fin' ifstream fin("livada_xi.in"); ^ gray.cpp:46:10: error: 'std::ifstream fin' previously declared here ifstream fin("pacman_xi.in"); ^ gray.cpp:118:14: error: redefinition of 'std::ofstream fout' ofstream fout("livada_xi.out"); ^ gray.cpp:47:10: error: 'std::ofstream fout' previously declared here ofstream fout("pacman_xi.out"); ^ gray.cpp: In function 'int main()': gray.cpp:119:5: error: redefinition of 'int main()' int main() ^ gray.cpp:11:5: error: 'int main()' previously defined here int main() ^ gray.cpp: At global scope: gray.cpp:146:13: error: redefinition of 'std::ifstream fin' ifstream fin("cladire1.in"); ^ gray.cpp:46:10: error: 'std::ifstream fin' previously declared here ifstream fin("pacman_xi.in"); ^ gray.cpp:147:14: error: redefinition of 'std::ofstream fout' ofstream fout("cladire1.out"); ^ gray.cpp:47:10: error: 'std::ofstream fout' previously declared here ofstream fout("pacman_xi.out"); ^ gray.cpp:149:5: error: redefinition of 'int n' int n , m , a[1001][1001]; ^ gray.cpp:7:5: error: 'int n' previously declared here int n; ^ gray.cpp:149:9: error: conflicting declaration 'int m' int n , m , a[1001][1001]; ^ gray.cpp:8:5: error: 'm' has a previous declaration as 'int m [102][102]' int m[102][102] = {{0}}; ^ gray.cpp:149:25: error: conflicting declaration 'int a [1001][1001]' int n , m , a[1001][1001]; ^ gray.cpp:49:15: error: 'a' has a previous declaration as 'long long int a [55][55]' long long n,m,a[55][55]; ^ gray.cpp: In function 'int main()': gray.cpp:153:5: error: redefinition of 'int main()' int main() ^ gray.cpp:11:5: error: 'int main()' previously defined here int main() ^ gray.cpp:155:9: error: cannot bind 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' fin >> n >> m >> k; ^ In file included from /usr/include/c++/4.8/iostream:40:0, from gray.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [102][102]]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ gray.cpp:163:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] for(int j = 1 ; j <= m ; j++) ^ gray.cpp:168:57: error: no matching function for call to 'max(long long int&, int)' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ gray.cpp:168:57: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, 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 gray.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: gray.cpp:168:57: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, 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 gray.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: gray.cpp:168:57: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from gray.cpp:42: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: gray.cpp:168:57: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from gray.cpp:42: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: gray.cpp:168:57: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ gray.cpp:168:80: error: no matching function for call to 'max(long long int&, int)' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ gray.cpp:168:80: note: candidates are: In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, 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 gray.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: gray.cpp:168:80: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0, 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 gray.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:260:5: note: template argument deduction/substitution failed: gray.cpp:168:80: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from gray.cpp:42: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: gray.cpp:168:80: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from gray.cpp:42: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: gray.cpp:168:80: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' a[i][j] = (a[i][j] + max(a[i - 1][j] , 0) + max(a[i][j - 1] , 0)) % 9901; ^ gray.cpp:170:19: error: invalid types 'long long int [55][int [102][102]]' for array subscript fout << a[n][m]; ^ gray.cpp: At global scope: gray.cpp:183:13: error: redefinition of 'std::ifstream fin' ifstream fin("alice_xi.in"); ^ gray.cpp:46:10: error: 'std::ifstream fin' previously declared here ifstream fin("pacman_xi.in"); ^ gray.cpp:184:14: error: redefinition of 'std::ofstream fout' ofstream fout("alice_xi.out"); ^ gray.cpp:47:10: error: 'std::ofstream fout' previously declared here ofstream fout("pacman_xi.out"); ^ gray.cpp:186:11: error: conflicting declaration 'long long int n' long long n, a[101][101]; ^ gray.cpp:7:5: error: 'n' has a previous declaration as 'int n' int n; ^ gray.cpp:186:24: error: conflicting declaration 'long long int a [101][101]' long long n, a[101][101]; ^ gray.cpp:49:15: error: 'a' has a previous declaration as 'long long int a [55][55]' long long n,m,a[55][55]; ^ gray.cpp: In function 'int main()': gray.cpp:188:5: error: redefinition of 'int main()' int main() ^ gray.cpp:11:5: error: 'int main()' previously defined here int main() ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Gray 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ă.