Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'Kristina has a matrix of size n by n , filled with lowercase Latin letters. The value of n is even. She wants to change some characters so that her matrix becomes a perfect square. A matrix is called a perfect square if it remains unchanged when rotated 90^ circ clockwise once. Here is an example of rotating a matrix by 90^ circ : In one operation, Kristina can choose any cell and replace its value with the next character in the alphabet. If the character is equal to "z", its value does not change. Find the minimum number of operations required to make the matrix a perfect square. For example, if the 4 by 4 matrix looks like this: matrix{ a & b & b & a cr b & c & textbf{b} & b cr b & c & c & b cr a & b & b & a cr } then it is enough to apply 1 operation to the letter b, highlighted in bold. The first line of the input contains a single integer t ( 1 <= t <= 10^2 ) -- the number of test cases. Then follows the description of each test case. The first line of each test case contains a single even integer n ( 2 <= n <= 10^3 ) -- the number of rows and columns in the matrix. Then follows n lines, each containing exactly n lowercase Latin letters. It is guaranteed that the sum of n over all test cases does not exceed 10^3 . For each test case, output a single number on a separate line: the minimum number of operations required for Kristina to obtain a perfect square. The first test case is explained in the problem statement. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
227953587 |
Derato |
C |
Oct. 12, 2023, 9:11 p.m. |
OK |
C# 10 |
TESTS |
7 |
109 |
5222400 |
|
|
227967300 |
bluemegane |
C |
Oct. 13, 2023, 2:28 a.m. |
OK |
C# 8 |
TESTS |
7 |
155 |
6963200 |
|
|
227953884 |
andrey.starodubtsev |
C |
Oct. 12, 2023, 9:16 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
7 |
265 |
3174400 |
|
|
227935526 |
GMode |
C |
Oct. 12, 2023, 5:52 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
7 |
156 |
1228800 |
|
|
227931663 |
soumitrasamanta506 |
C |
Oct. 12, 2023, 5:23 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
7 |
857 |
4198400 |
|
|
227937650 |
pash18i5 |
C |
Oct. 12, 2023, 6:09 p.m. |
OK |
GNU C11 |
TESTS |
7 |
15 |
1024000 |
|
|
227924888 |
cit14 |
C |
Oct. 12, 2023, 4:52 p.m. |
OK |
GNU C11 |
TESTS |
7 |
156 |
1024000 |
|
|
227969021 |
gugubird13 |
C |
Oct. 13, 2023, 2:56 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1024000 |
|
|
227969635 |
peter112358 |
C |
Oct. 13, 2023, 3:07 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1024000 |
|
|
227961787 |
y_kx_b |
C |
Oct. 13, 2023, 12:35 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1331200 |
|
|
227942635 |
Yato. |
C |
Oct. 12, 2023, 6:53 p.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1843200 |
|
|
227932185 |
anonymous_01 |
C |
Oct. 12, 2023, 5:26 p.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1945600 |
|
|
227943723 |
nikhilkumarv |
C |
Oct. 12, 2023, 7:04 p.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
1945600 |
|
|
227962519 |
zltzlt |
C |
Oct. 13, 2023, 12:53 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
2048000 |
|
|
227977680 |
HoangMC2009 |
C |
Oct. 13, 2023, 5:04 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
2867200 |
|
|
227967548 |
bkifhr9 |
C |
Oct. 13, 2023, 2:32 a.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
4096000 |
|
|
227927443 |
aditya0610 |
C |
Oct. 12, 2023, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
7 |
15 |
10547200 |
|
|
227979319 |
Harshanandita |
C |
Oct. 13, 2023, 5:25 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227965754 |
Earloar |
C |
Oct. 13, 2023, 2 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227958065 |
Sunr1zeGG |
C |
Oct. 12, 2023, 10:50 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227940876 |
Shubham.Jain |
C |
Oct. 12, 2023, 6:36 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227940543 |
EvenToWorldFinal |
C |
Oct. 12, 2023, 6:33 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227982010 |
abohamzanatt |
C |
Oct. 13, 2023, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227933555 |
Luenly |
C |
Oct. 12, 2023, 5:36 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227932809 |
MOHD_FAIZ |
C |
Oct. 12, 2023, 5:30 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227982040 |
Mizbah01 |
C |
Oct. 13, 2023, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227940510 |
EVENBAO |
C |
Oct. 12, 2023, 6:33 p.m. |
OK |
GNU C++17 |
TESTS |
7 |
15 |
1024000 |
|
|
227959467 |
chappy1 |
C |
Oct. 12, 2023, 11:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
0 |
1740800 |
|
|
227941700 |
Ahmed_Bahy |
C |
Oct. 12, 2023, 6:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1024000 |
|
|
227971330 |
Chen_zy |
C |
Oct. 13, 2023, 3:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1024000 |
|
|
227974051 |
koushikad |
C |
Oct. 13, 2023, 4:12 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1740800 |
|
|
227968823 |
nUbOrZzz |
C |
Oct. 13, 2023, 2:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1843200 |
|
|
227940496 |
ALuca_Rd |
C |
Oct. 12, 2023, 6:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1843200 |
|
|
227978769 |
mirror01 |
C |
Oct. 13, 2023, 5:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1843200 |
|
|
227956390 |
enslaved |
C |
Oct. 12, 2023, 10:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
1843200 |
|
|
227928046 |
dailydreamer |
C |
Oct. 12, 2023, 5:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
15 |
3072000 |
|
|
227948746 |
felipedosantosabino1 |
C |
Oct. 12, 2023, 8:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
7 |
30 |
1024000 |
|
|
227965328 |
karen114514 |
C |
Oct. 13, 2023, 1:51 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1126400 |
|
|
227962948 |
DybalaFFF765657 |
C |
Oct. 13, 2023, 1:03 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1126400 |
|
|
227960886 |
yrsmy |
C |
Oct. 13, 2023, 12:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1126400 |
|
|
227968238 |
August.666 |
C |
Oct. 13, 2023, 2:43 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1126400 |
|
|
227948826 |
Tushargoyal |
C |
Oct. 12, 2023, 8:02 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227969115 |
Towhed_17 |
C |
Oct. 13, 2023, 2:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227969080 |
2021331089T |
C |
Oct. 13, 2023, 2:57 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227968942 |
haochenlyu |
C |
Oct. 13, 2023, 2:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227940184 |
_abhi_08 |
C |
Oct. 12, 2023, 6:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227939420 |
vshal |
C |
Oct. 12, 2023, 6:24 p.m. |
OK |
GNU C++20 (64) |
TESTS |
7 |
0 |
1228800 |
|
|
227977465 |
Panther369 |
C |
Oct. 13, 2023, 5:01 a.m. |
OK |
Java 11 |
TESTS |
7 |
171 |
0 |
|
|
227956792 |
DOOMJUICE |
C |
Oct. 12, 2023, 10:17 p.m. |
OK |
Java 11 |
TESTS |
7 |
187 |
0 |
|
|
227955716 |
themadknight45 |
C |
Oct. 12, 2023, 9:54 p.m. |
OK |
Java 11 |
TESTS |
7 |
187 |
0 |
|
|
227945845 |
anonuser |
C |
Oct. 12, 2023, 7:26 p.m. |
OK |
Java 11 |
TESTS |
7 |
218 |
0 |
|
|
227928219 |
saurabhtrigunayat90 |
C |
Oct. 12, 2023, 5:04 p.m. |
OK |
Java 11 |
TESTS |
7 |
218 |
0 |
|
|
227971991 |
ljjkr |
C |
Oct. 13, 2023, 3:42 a.m. |
OK |
Java 11 |
TESTS |
7 |
233 |
0 |
|
|
227935140 |
chemvuong |
C |
Oct. 12, 2023, 5:48 p.m. |
OK |
Java 11 |
TESTS |
7 |
233 |
0 |
|
|
227929963 |
beka001 |
C |
Oct. 12, 2023, 5:13 p.m. |
OK |
Java 11 |
TESTS |
7 |
280 |
0 |
|
|
227925904 |
sk99sk |
C |
Oct. 12, 2023, 4:55 p.m. |
OK |
Java 11 |
TESTS |
7 |
608 |
1126400 |
|
|
227962515 |
dilshar23 |
C |
Oct. 13, 2023, 12:53 a.m. |
OK |
Java 17 |
TESTS |
7 |
171 |
0 |
|
|
227961505 |
the_unseen |
C |
Oct. 13, 2023, 12:27 a.m. |
OK |
Java 17 |
TESTS |
7 |
186 |
409600 |
|
|
227930234 |
AKhacks |
C |
Oct. 12, 2023, 5:14 p.m. |
OK |
Java 17 |
TESTS |
7 |
217 |
614400 |
|
|
227944220 |
flicktoss |
C |
Oct. 12, 2023, 7:10 p.m. |
OK |
Java 17 |
TESTS |
7 |
233 |
204800 |
|
|
227925240 |
mohsin4k |
C |
Oct. 12, 2023, 4:53 p.m. |
OK |
Java 17 |
TESTS |
7 |
233 |
614400 |
|
|
227955691 |
vikash_45 |
C |
Oct. 12, 2023, 9:53 p.m. |
OK |
Java 17 |
TESTS |
7 |
249 |
512000 |
|
|
227953747 |
nikhil6g |
C |
Oct. 12, 2023, 9:13 p.m. |
OK |
Java 17 |
TESTS |
7 |
249 |
614400 |
|
|
227942807 |
vikasseervi357 |
C |
Oct. 12, 2023, 6:55 p.m. |
OK |
Java 17 |
TESTS |
7 |
249 |
716800 |
|
|
227941470 |
namansarda2007 |
C |
Oct. 12, 2023, 6:42 p.m. |
OK |
Java 17 |
TESTS |
7 |
249 |
716800 |
|
|
227938130 |
vaibhav_1710 |
C |
Oct. 12, 2023, 6:13 p.m. |
OK |
Java 17 |
TESTS |
7 |
264 |
716800 |
|
|
227930439 |
d2s2 |
C |
Oct. 12, 2023, 5:15 p.m. |
OK |
Java 21 |
TESTS |
7 |
218 |
0 |
|
|
227982205 |
Danger_Don |
C |
Oct. 13, 2023, 5:57 a.m. |
OK |
Java 8 |
TESTS |
7 |
109 |
0 |
|
|
227937953 |
priyaroy3370 |
C |
Oct. 12, 2023, 6:12 p.m. |
OK |
Java 8 |
TESTS |
7 |
124 |
5632000 |
|
|
227975227 |
prakhar_30 |
C |
Oct. 13, 2023, 4:31 a.m. |
OK |
Java 8 |
TESTS |
7 |
140 |
4096000 |
|
|
227945762 |
sumitlaura101 |
C |
Oct. 12, 2023, 7:26 p.m. |
OK |
Java 8 |
TESTS |
7 |
155 |
5939200 |
|
|
227940326 |
Sumitsingh7 |
C |
Oct. 12, 2023, 6:31 p.m. |
OK |
Java 8 |
TESTS |
7 |
155 |
5939200 |
|
|
227966958 |
duisheng |
C |
Oct. 13, 2023, 2:23 a.m. |
OK |
Java 8 |
TESTS |
7 |
171 |
0 |
|
|
227931073 |
AbhayTiwari007 |
C |
Oct. 12, 2023, 5:19 p.m. |
OK |
Java 8 |
TESTS |
7 |
171 |
0 |
|
|
227943019 |
jdtheripperpc |
C |
Oct. 12, 2023, 6:57 p.m. |
OK |
Java 8 |
TESTS |
7 |
186 |
4300800 |
|
|
227931080 |
Aldijohn |
C |
Oct. 12, 2023, 5:19 p.m. |
OK |
Java 8 |
TESTS |
7 |
187 |
0 |
|
|
227972462 |
vaasuu |
C |
Oct. 13, 2023, 3:49 a.m. |
OK |
Java 8 |
TESTS |
7 |
218 |
0 |
|
|
227928036 |
agcom |
C |
Oct. 12, 2023, 5:04 p.m. |
OK |
Kotlin 1.7 |
TESTS |
7 |
1247 |
90828800 |
|
|
227936357 |
tatianyi |
C |
Oct. 12, 2023, 5:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
46 |
1433600 |
|
|
227959613 |
AvanSingh |
C |
Oct. 12, 2023, 11:35 p.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
124 |
1228800 |
|
|
227932318 |
ExtractStars |
C |
Oct. 12, 2023, 5:27 p.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
124 |
4403200 |
|
|
227978370 |
Akhil_09 |
C |
Oct. 13, 2023, 5:13 a.m. |
OK |
MS C++ 2017 |
TESTS |
7 |
296 |
1331200 |
|
|
227948241 |
GeshaIliiasova |
C |
Oct. 12, 2023, 7:55 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
218 |
5939200 |
|
|
227953997 |
ebesso |
C |
Oct. 12, 2023, 9:18 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
342 |
88883200 |
|
|
227925573 |
mahnameisayush |
C |
Oct. 12, 2023, 4:54 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
343 |
25395200 |
|
|
227932275 |
Antinae_MiHawk |
C |
Oct. 12, 2023, 5:27 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
358 |
27955200 |
|
|
227932146 |
Antonio_Colapso_07 |
C |
Oct. 12, 2023, 5:26 p.m. |
OK |
PyPy 3 |
TESTS |
7 |
421 |
6041600 |
|
|
227978461 |
hato_ |
C |
Oct. 13, 2023, 5:14 a.m. |
OK |
PyPy 3 |
TESTS |
7 |
858 |
72192000 |
|
|
227965641 |
Learn_cute_k |
C |
Oct. 13, 2023, 1:57 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
109 |
6041600 |
|
|
227931974 |
Nullz |
C |
Oct. 12, 2023, 5:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
124 |
4608000 |
|
|
227973002 |
brightest66 |
C |
Oct. 13, 2023, 3:58 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
124 |
4812800 |
|
|
227938240 |
sbdkdlalit0112 |
C |
Oct. 12, 2023, 6:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
124 |
5632000 |
|
|
227961442 |
Sam_Jiang |
C |
Oct. 13, 2023, 12:25 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
124 |
8192000 |
|
|
227948164 |
GeshaIliiasova |
C |
Oct. 12, 2023, 7:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
140 |
4812800 |
|
|
227950994 |
kechua |
C |
Oct. 12, 2023, 8:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
140 |
15257600 |
|
|
227933387 |
prateek.goel.cs.2019 |
C |
Oct. 12, 2023, 5:34 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
155 |
9318400 |
|
|
227969551 |
Imeon |
C |
Oct. 13, 2023, 3:05 a.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
155 |
13619200 |
|
|
227945694 |
gardengnome |
C |
Oct. 12, 2023, 7:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
7 |
155 |
15257600 |
|
|
227926919 |
AnonI201 |
C |
Oct. 12, 2023, 4:59 p.m. |
OK |
Python 3 |
TESTS |
7 |
265 |
10035200 |
|
|
227978068 |
starpacker |
C |
Oct. 13, 2023, 5:09 a.m. |
OK |
Python 3 |
TESTS |
7 |
280 |
1433600 |
|
|
227949166 |
GeshaIliiasova |
C |
Oct. 12, 2023, 8:07 p.m. |
OK |
Python 3 |
TESTS |
7 |
280 |
1433600 |
|
|
227965566 |
Shineeee |
C |
Oct. 13, 2023, 1:56 a.m. |
OK |
Python 3 |
TESTS |
7 |
280 |
9830400 |
|
|
227941358 |
YuRen-tw |
C |
Oct. 12, 2023, 6:41 p.m. |
OK |
Python 3 |
TESTS |
7 |
280 |
10752000 |
|
|
227949372 |
ex_nihilo |
C |
Oct. 12, 2023, 8:09 p.m. |
OK |
Python 3 |
TESTS |
7 |
327 |
1433600 |
|
|
227948088 |
GeshaIliiasova |
C |
Oct. 12, 2023, 7:53 p.m. |
OK |
Python 3 |
TESTS |
7 |
327 |
1433600 |
|
|
227940975 |
ZsoldosP |
C |
Oct. 12, 2023, 6:37 p.m. |
OK |
Python 3 |
TESTS |
7 |
327 |
1433600 |
|
|
227932249 |
LuFeGu |
C |
Oct. 12, 2023, 5:27 p.m. |
OK |
Python 3 |
TESTS |
7 |
342 |
9420800 |
|
|
227948570 |
GeshaIliiasova |
C |
Oct. 12, 2023, 7:59 p.m. |
OK |
Python 3 |
TESTS |
7 |
373 |
1433600 |
|
|
remove filters
Back to search problems