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'Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating." The class can be represented as a matrix with n rows and m columns with a student in each cell. Two students are neighbors if cells in which they sit have a common side. Let 's enumerate students from 1 to n xc2 xb7m in order of rows. So a student who initially sits in the cell in row i and column j has a number (i xe2 x80 x89- xe2 x80 x891) xc2 xb7m xe2 x80 x89+ xe2 x80 x89j. You have to find a matrix with n rows and m columns in which all numbers from 1 to n xc2 xb7m appear exactly once and adjacent numbers in the original matrix are not adjacent in it, or determine that there is no such matrix. The only line contains two integers n and m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105; n xc2 xb7m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) -- the number of rows and the number of columns in the required matrix. If there is no such matrix, output "NO" (without quotes). Otherwise in the first line output "YES" (without quotes), and in the next n lines output m integers which form the required matrix. In the first test case the matrix initially looks like this: It 's easy to see that there are no two students that are adjacent in both matrices. In the second test case there are only two possible seatings and in both of them students with numbers 1 and 2 are neighbors. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
33551501 |
yosupo |
B |
Dec. 23, 2017, 2:40 p.m. |
OK |
D |
TESTS |
42 |
78 |
14745600 |
|
2300 |
33608199 |
AsahiKasugano |
B |
Dec. 25, 2017, 4:21 a.m. |
OK |
FPC |
TESTS |
42 |
186 |
3174400 |
|
2300 |
33608189 |
KagamiharaNadeshiko |
B |
Dec. 25, 2017, 4:21 a.m. |
OK |
FPC |
TESTS |
42 |
186 |
3174400 |
|
2300 |
40255999 |
chaorenhaha |
B |
July 13, 2018, 9:05 a.m. |
OK |
FPC |
TESTS |
42 |
218 |
3174400 |
|
2300 |
40256007 |
chaorenhaha |
B |
July 13, 2018, 9:05 a.m. |
OK |
FPC |
TESTS |
42 |
327 |
3584000 |
|
2300 |
34428796 |
Scut82 |
B |
Jan. 22, 2018, 1:42 a.m. |
OK |
GNU C++ |
TESTS |
42 |
15 |
2867200 |
|
2300 |
34406914 |
Scut82 |
B |
Jan. 21, 2018, 8:58 a.m. |
OK |
GNU C++ |
TESTS |
42 |
15 |
3891200 |
|
2300 |
34407715 |
Scut82 |
B |
Jan. 21, 2018, 9:27 a.m. |
OK |
GNU C++ |
TESTS |
42 |
30 |
5939200 |
|
2300 |
34428458 |
Scut82 |
B |
Jan. 22, 2018, 1:25 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2048000 |
|
2300 |
34728640 |
vjudge4 |
B |
Jan. 31, 2018, 6:49 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2252800 |
|
2300 |
33581662 |
ghostfly233 |
B |
Dec. 24, 2017, 1:24 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2252800 |
|
2300 |
34406041 |
liuaohanjsj |
B |
Jan. 21, 2018, 8:29 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2457600 |
|
2300 |
33564743 |
skywalkert |
B |
Dec. 23, 2017, 3:37 p.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2457600 |
|
2300 |
33659891 |
wh2001_ZY |
B |
Dec. 27, 2017, 2:58 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2560000 |
|
2300 |
34880087 |
vjudge4 |
B |
Feb. 3, 2018, 2:15 a.m. |
OK |
GNU C++ |
TESTS |
42 |
31 |
2867200 |
|
2300 |
33572171 |
Torta |
B |
Dec. 23, 2017, 4:45 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2048000 |
|
2300 |
33571968 |
shanquan2 |
B |
Dec. 23, 2017, 4:42 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2048000 |
|
2300 |
57781750 |
TianZuiXing |
B |
July 26, 2019, 6:14 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2252800 |
|
2300 |
33575543 |
kipa00 |
B |
Dec. 23, 2017, 6:29 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2252800 |
|
2300 |
33583059 |
Stronger2020 |
B |
Dec. 24, 2017, 3:55 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2457600 |
|
2300 |
33559419 |
Shimatsukaze |
B |
Dec. 23, 2017, 3:11 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2457600 |
|
2300 |
38700906 |
mk_Shahriar |
B |
May 28, 2018, 5:35 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2560000 |
|
2300 |
33564149 |
IohcEjnim |
B |
Dec. 23, 2017, 3:35 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2662400 |
|
2300 |
35195716 |
zlc1114 |
B |
Feb. 13, 2018, 9:55 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2867200 |
|
2300 |
33620452 |
shdut |
B |
Dec. 25, 2017, 3:17 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
31 |
2867200 |
|
2300 |
33572133 |
shadowatyy |
B |
Dec. 23, 2017, 4:44 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
2867200 |
|
2300 |
33643117 |
sincerity |
B |
Dec. 26, 2017, 10 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
15 |
5632000 |
|
2300 |
33560172 |
Hujiwara |
B |
Dec. 23, 2017, 3:15 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
1945600 |
|
2300 |
33826587 |
Juanito98 |
B |
Dec. 31, 2017, 7:23 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
2662400 |
|
2300 |
33829283 |
yottacto |
B |
Dec. 31, 2017, 10:17 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
3072000 |
|
2300 |
33566584 |
V--o_o--V |
B |
Dec. 23, 2017, 3:47 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
3072000 |
|
2300 |
33576346 |
Denisson |
B |
Dec. 23, 2017, 7:03 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
3379200 |
|
2300 |
33564758 |
bazsi700 |
B |
Dec. 23, 2017, 3:37 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
3379200 |
|
2300 |
33571644 |
AomeII |
B |
Dec. 23, 2017, 4:38 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
4096000 |
|
2300 |
35082735 |
iaojnh |
B |
Feb. 9, 2018, 8:19 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
30 |
4198400 |
|
2300 |
36528920 |
vjudge5 |
B |
March 23, 2018, 11:44 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
31 |
7065600 |
|
2300 |
47621901 |
luogu_bot4 |
B |
Dec. 28, 2018, 1:11 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
1638400 |
|
2300 |
47621855 |
luogu_bot1 |
B |
Dec. 28, 2018, 1:10 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
1638400 |
|
2300 |
53422788 |
giuseppe55 |
B |
April 27, 2019, 12:16 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
3788800 |
|
2300 |
41252682 |
Gediminas |
B |
Aug. 5, 2018, 5:24 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
3788800 |
|
2300 |
41581439 |
pulkitg10 |
B |
Aug. 14, 2018, 8:17 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
3891200 |
|
2300 |
54830505 |
E869120 |
B |
May 30, 2019, 8:42 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
4403200 |
|
2300 |
38807871 |
yaksha |
B |
May 31, 2018, 4:15 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
6348800 |
|
2300 |
63188651 |
vjudge4 |
B |
Oct. 22, 2019, 4:50 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
8396800 |
|
2300 |
57827024 |
TianZuiXing |
B |
July 27, 2019, 3:49 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
46 |
8396800 |
|
2300 |
34213973 |
kingsnow |
B |
Jan. 16, 2018, 6:25 a.m. |
OK |
GNU C++17 Diagnostics |
TESTS |
42 |
1279 |
108134400 |
|
2300 |
33575565 |
Ekler |
B |
Dec. 23, 2017, 6:30 p.m. |
OK |
GNU C++17 Diagnostics |
TESTS |
42 |
1575 |
102912000 |
|
2300 |
33572529 |
b92paul |
B |
Dec. 23, 2017, 4:50 p.m. |
OK |
GNU C++17 Diagnostics |
TESTS |
42 |
1684 |
103731200 |
|
2300 |
34163447 |
tri |
B |
Jan. 13, 2018, 11:34 p.m. |
OK |
Java 8 |
TESTS |
42 |
140 |
20787200 |
|
2300 |
33635967 |
Ruins |
B |
Dec. 26, 2017, 4:21 a.m. |
OK |
Java 8 |
TESTS |
42 |
140 |
20787200 |
|
2300 |
33564351 |
alexyz |
B |
Dec. 23, 2017, 3:35 p.m. |
OK |
Java 8 |
TESTS |
42 |
155 |
20787200 |
|
2300 |
33658137 |
JialinOuyang |
B |
Dec. 26, 2017, 10:23 p.m. |
OK |
Java 8 |
TESTS |
42 |
155 |
20787200 |
|
2300 |
33552782 |
uwi |
B |
Dec. 23, 2017, 2:45 p.m. |
OK |
Java 8 |
TESTS |
42 |
155 |
20889600 |
|
2300 |
33564702 |
hiromi_ayase |
B |
Dec. 23, 2017, 3:37 p.m. |
OK |
Java 8 |
TESTS |
42 |
155 |
20992000 |
|
2300 |
33571579 |
aabdelzaher |
B |
Dec. 23, 2017, 4:37 p.m. |
OK |
Java 8 |
TESTS |
42 |
156 |
20787200 |
|
2300 |
33571916 |
Azat_Yusupov |
B |
Dec. 23, 2017, 4:41 p.m. |
OK |
Java 8 |
TESTS |
42 |
170 |
22118400 |
|
2300 |
33576083 |
dusty.and.rusty |
B |
Dec. 23, 2017, 6:51 p.m. |
OK |
Java 8 |
TESTS |
42 |
171 |
20787200 |
|
2300 |
33645156 |
vovacomua |
B |
Dec. 26, 2017, 11:25 a.m. |
OK |
Java 8 |
TESTS |
42 |
202 |
20889600 |
|
2300 |
33574168 |
kuuso |
B |
Dec. 23, 2017, 5:30 p.m. |
OK |
Mono C# |
TESTS |
42 |
249 |
22425600 |
|
2300 |
33562076 |
16silver |
B |
Dec. 23, 2017, 3:24 p.m. |
OK |
MS C++ |
TESTS |
42 |
31 |
2048000 |
|
2300 |
34060326 |
RCG |
B |
Jan. 10, 2018, 1:54 a.m. |
OK |
MS C++ |
TESTS |
42 |
31 |
3276800 |
|
2300 |
33557233 |
natalia |
B |
Dec. 23, 2017, 3:01 p.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
2867200 |
|
2300 |
57824379 |
TianSunXing |
B |
July 27, 2019, 2:03 a.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
4403200 |
|
2300 |
57824351 |
TianJianXing |
B |
July 27, 2019, 2:02 a.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
4403200 |
|
2300 |
57808711 |
TianPingXing |
B |
July 26, 2019, 4:16 p.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
4403200 |
|
2300 |
41296460 |
vjudge1 |
B |
Aug. 7, 2018, 7:28 a.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
4403200 |
|
2300 |
33578879 |
caa_tomsk |
B |
Dec. 23, 2017, 9:31 p.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
5632000 |
|
2300 |
62094017 |
vjudge1 |
B |
Oct. 8, 2019, 6:50 a.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
6041600 |
|
2300 |
57795519 |
TianPingXing |
B |
July 26, 2019, 11:15 a.m. |
OK |
MS C++ |
TESTS |
42 |
46 |
6041600 |
|
2300 |
57796206 |
TianJianXing |
B |
July 26, 2019, 11:30 a.m. |
OK |
MS C++ 2017 |
TESTS |
42 |
46 |
1638400 |
|
2300 |
57749214 |
codemaster4 |
B |
July 25, 2019, 2:10 p.m. |
OK |
PHP |
TESTS |
42 |
1013 |
12595200 |
|
2300 |
57780155 |
TianJianXing |
B |
July 26, 2019, 5:38 a.m. |
OK |
PHP |
TESTS |
42 |
1029 |
12185600 |
|
2300 |
57749425 |
codemaster4 |
B |
July 25, 2019, 2:15 p.m. |
OK |
PHP |
TESTS |
42 |
1029 |
12185600 |
|
2300 |
38987668 |
Ali_Pi |
B |
June 6, 2018, 8 a.m. |
OK |
PyPy 3 |
TESTS |
42 |
343 |
7680000 |
|
2300 |
33581788 |
WNG |
B |
Dec. 24, 2017, 1:37 a.m. |
OK |
Python 2 |
TESTS |
42 |
327 |
23449600 |
|
2300 |
33589059 |
nwi |
B |
Dec. 24, 2017, 9:18 a.m. |
OK |
Python 2 |
TESTS |
42 |
1856 |
29900800 |
|
2300 |
44053581 |
cortan122 |
B |
Oct. 9, 2018, 8:55 p.m. |
OK |
Python 3 |
TESTS |
42 |
327 |
2355200 |
|
2300 |
33669747 |
Jiburiru |
B |
Dec. 27, 2017, 1:26 p.m. |
OK |
Python 3 |
TESTS |
42 |
670 |
8908800 |
|
2300 |
33864379 |
PEDY4000 |
B |
Jan. 2, 2018, 1:17 p.m. |
OK |
Python 3 |
TESTS |
42 |
826 |
23040000 |
|
2300 |
42132593 |
Mk_Python_v1 |
B |
Aug. 26, 2018, 7:35 p.m. |
OK |
Python 3 |
TESTS |
42 |
951 |
17817600 |
|
2300 |
33560496 |
ichyo |
B |
Dec. 23, 2017, 3:16 p.m. |
OK |
Rust |
TESTS |
42 |
514 |
2969600 |
|
2300 |
remove filters
Back to search problems