#2966
yinyang
Se dă o matrice A
cu N
linii și M
coloane, cu valori cuprinse între 1 și N∙M
inclusiv, nu neapărat distincte. O operație constă în selectarea a două linii sau două coloane consecutive și interschimbarea acestora (swap). O matrice yin-yang
este o matrice în care A[ i ] [ j ] ≥ A[ i ][ j – 1]
, pentru orice pereche (i, j)
cu 1 ≤ i ≤ N
și 2 ≤ j ≤ M
și A[ i ][ j ] ≥ A[ i – 1][ j ]
, pentru orice pereche (i, j)
cu 2 ≤ i ≤ N
și 1 ≤ j ≤ M
.
Să se determine numărul minim de operații necesare pentru a transforma matricea dată într-o matrice yin-yang
.
OJI 2019
Problema | yinyang | Operații I/O |
yinyang.in /yinyang.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #51948702 | Utilizator | |
Fișier | yinyang.cpp | Dimensiune | 1.91 KB |
Data încărcării | 11 Septembrie 2024, 21:35 | Scor / rezultat | Eroare de compilare |
yinyang.cpp: In function 'void sortMat()': yinyang.cpp:46:17: error: incompatible types in assignment of 'int' to 'int [104]' cind[i] = i; ^ yinyang.cpp:52:44: error: invalid types 'int [104][int [104]]' for array subscript nm[i][j] = mat[lind[i]][cind[j]]; ^ 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 yinyang.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]': /usr/include/c++/4.8/bits/stl_algo.h:2226:70: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5500:55: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' yinyang.cpp:48:41: required from here /usr/include/c++/4.8/bits/stl_algo.h:2159:29: error: invalid conversion from 'int*' to 'int' [-fpermissive] if (__comp(*__i, *__first)) ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, 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/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 yinyang.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:2162:11: error: array must be initialized with a brace-enclosed initializer __val = _GLIBCXX_MOVE(*__i); ^ 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 yinyang.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:2164:17: error: invalid array assignment *__first = _GLIBCXX_MOVE(__val); ^ /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]': /usr/include/c++/4.8/bits/stl_algo.h:5349:59: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:2332:68: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int (*)[104]; _Size = int; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' yinyang.cpp:48:41: required from here /usr/include/c++/4.8/bits/stl_algo.h:1948:27: error: invalid conversion from 'int*' to 'int' [-fpermissive] if (__comp(*__i, *__first)) ^ /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]': /usr/include/c++/4.8/bits/stl_algo.h:2295:13: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int (*)[104]; _Size = int; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' yinyang.cpp:48:41: required from here /usr/include/c++/4.8/bits/stl_algo.h:114:28: error: invalid conversion from 'int*' to 'int' [-fpermissive] if (__comp(*__a, *__b)) ^ /usr/include/c++/4.8/bits/stl_algo.h:116:25: error: invalid conversion from 'int*' to 'int' [-fpermissive] if (__comp(*__b, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:118:30: error: invalid conversion from 'int*' to 'int' [-fpermissive] else if (__comp(*__a, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:123:33: error: invalid conversion from 'int*' to 'int' [-fpermissive] else if (__comp(*__a, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:125:33: error: invalid conversion from 'int*' to 'int' [-fpermissive] else if (__comp(*__b, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = int (*)[104]; _Tp = int [104]; _Compare = int (*)(const int&, const int&)]': /usr/include/c++/4.8/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int (*)[104]; _Size = int; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' yinyang.cpp:48:41: required from here /usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: invalid conversion from 'int*' to 'int' [-fpermissive] while (__comp(*__first, __pivot)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2266:34: error: invalid conversion from 'const int*' to 'int' [-fpermissive] while (__comp(__pivot, *__last)) ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, 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/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 yinyang.cpp:1: /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::make_heap(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]': /usr/include/c++/4.8/bits/stl_algo.h:1946:47: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5349:59: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:2332:68: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int (*)[104]; _Size = int; _Compare = int (*)(const int&, const int&)]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = int (*)[104]; _Compare = int (*)(const int&, const int&)]' yinyang.cpp:48:41: required from here /usr/include/c++/4.8/bits/stl_heap.h:446:25: error: array must be initialized with a brace-enclosed initializer _ValueType __value = _GLIBCXX_MOVE(*(__first + __parent)); ^ yinyang.cpp: In function 'void readInput()': yinyang.cpp:12:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d" , &n , &m); ^ yinyang.cpp:16:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&mat[i][j]); ^ yinyang.cpp: In function 'int main()': yinyang.cpp:86:36: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("yinyang.in","r",stdin); ^ yinyang.cpp:87:38: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("yinyang.out","w",stdout); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema yinyang 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ă.