Codeforces Round 783 (Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1668 Codeforces Round 783 (Div. 2) FINISHED False 7200 81444299 April 19, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 16354 ) A Direction Change PROGRAMMING implementation math 800

B'You are given a grid with n rows and m columns. Rows and columns are numbered from 1 to n , and from 1 to m . The intersection of the a -th row and b -th column is denoted by (a, b) . Initially, you are standing in the top left corner (1, 1) . Your goal is to reach the bottom right corner (n, m) . You can move in four directions from (a, b) : up to (a-1, b) , down to (a+1, b) , left to (a, b-1) or right to (a, b+1) . You cannot move in the same direction in two consecutive moves, and you cannot leave the grid. What is the minimum number of moves to reach (n, m) ? The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^3 ) -- the number of the test cases. The description of the test cases follows. The first line of each test case contains two integers n and m ( 1 <= n, m <= 10^9 ) -- the size of the grid. For each test case, print a single integer: -1 if it is impossible to reach (n, m) under the given conditions, otherwise the minimum number of moves. Test case 1 : n=1 , m=1 , and initially you are standing in (1, 1) so 0 move is required to reach (n, m) = (1, 1) . Test case 2 : you should go down to reach (2, 1) . Test case 3 : it is impossible to reach (1, 3) without moving right two consecutive times, or without leaving the grid. Test case 4 : an optimal moving sequence could be: (1, 1) to (1, 2) to (2, 2) to (2, 1) to (3, 1) to (3, 2) to (4, 2) . It can be proved that this is the optimal solution. So the answer is 6 . '...

Tutorials

Codeforces Round #783 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
154175623 rajeshsr A April 20, 2022, 7:34 a.m. OK Clang++17 Diagnostics TESTS 18 31 0 800
154796374 Pendem A April 23, 2022, 11:44 p.m. OK Clang++17 Diagnostics TESTS 18 31 0 800
154150826 1287971889 A April 19, 2022, 11:01 p.m. OK Clang++17 Diagnostics TESTS 18 46 0 800
154264011 AdnanulIslam A April 21, 2022, 9:58 a.m. OK Clang++17 Diagnostics TESTS 18 46 0 800
154455339 Mohit-sankhla02 A April 22, 2022, 2:54 a.m. OK Clang++17 Diagnostics TESTS 18 46 0 800
154265575 LiuYiWen A April 21, 2022, 10:22 a.m. OK GNU C11 TESTS 18 15 0 800
154267406 Pandora999 A April 21, 2022, 10:38 a.m. OK GNU C11 TESTS 18 15 0 800
154817969 Deep1809 A April 24, 2022, 6:55 a.m. OK GNU C11 TESTS 18 15 0 800
154188908 Gold_Dragon A April 20, 2022, 10:53 a.m. OK GNU C11 TESTS 18 15 0 800
154190958 drfahim A April 20, 2022, 11:21 a.m. OK GNU C11 TESTS 18 15 0 800
154222226 predawn A April 20, 2022, 6:18 p.m. OK GNU C11 TESTS 18 15 0 800
154254157 adarshayush9939 A April 21, 2022, 7:18 a.m. OK GNU C11 TESTS 18 15 0 800
154260682 chinawcp A April 21, 2022, 9:11 a.m. OK GNU C11 TESTS 18 15 0 800
154170134 I_AM_LIGHTENING A April 20, 2022, 6:12 a.m. OK GNU C11 TESTS 18 15 0 800
154184521 I_AM_LIGHTENING A April 20, 2022, 9:50 a.m. OK GNU C11 TESTS 18 15 0 800
154166809 Dragoningw A April 20, 2022, 5:18 a.m. OK GNU C++14 TESTS 18 0 0 800
154171911 Xerxes_2002 A April 20, 2022, 6:39 a.m. OK GNU C++14 TESTS 18 0 0 800
154607276 Sawan73 A April 23, 2022, 1:20 a.m. OK GNU C++14 TESTS 18 0 0 800
154148649 pastilia A April 19, 2022, 9:56 p.m. OK GNU C++14 TESTS 18 0 0 800
154171792 Hush A April 20, 2022, 6:37 a.m. OK GNU C++14 TESTS 18 0 409600 800
154900902 Galaxy299 A April 25, 2022, 3:36 a.m. OK GNU C++14 TESTS 18 15 0 800
154902444 risso0529 A April 25, 2022, 4:12 a.m. OK GNU C++14 TESTS 18 15 0 800
154903395 An_cien A April 25, 2022, 4:35 a.m. OK GNU C++14 TESTS 18 15 0 800
154906466 bingzhihuihen A April 25, 2022, 5:38 a.m. OK GNU C++14 TESTS 18 15 0 800
154902308 An_cien A April 25, 2022, 4:08 a.m. OK GNU C++14 TESTS 18 15 0 800
154285467 Rosed A April 21, 2022, 2:18 p.m. OK GNU C++17 TESTS 18 0 0 800
154672880 the_white_devil A April 23, 2022, 1:01 p.m. OK GNU C++17 TESTS 18 0 0 800
154807224 singh24vishal A April 24, 2022, 4:22 a.m. OK GNU C++17 TESTS 18 0 0 800
154228491 KemoCode A April 20, 2022, 8:23 p.m. OK GNU C++17 TESTS 18 0 0 800
154241555 tomoyocedar A April 21, 2022, 2:33 a.m. OK GNU C++17 TESTS 18 0 0 800
154261425 Kit-Cat A April 21, 2022, 9:25 a.m. OK GNU C++17 TESTS 18 0 0 800
154207648 Himanshujoy A April 20, 2022, 2:41 p.m. OK GNU C++17 TESTS 18 0 0 800
154199675 Ebiswas7516 A April 20, 2022, 1:05 p.m. OK GNU C++17 TESTS 18 0 0 800
154198500 parth_1205 A April 20, 2022, 12:53 p.m. OK GNU C++17 TESTS 18 0 0 800
154193488 anchit00004 A April 20, 2022, 11:52 a.m. OK GNU C++17 TESTS 18 0 0 800
154222568 julianferres A April 20, 2022, 6:24 p.m. OK GNU C++17 (64) TESTS 18 0 0 800
154471805 UN_predictable A April 22, 2022, 7:13 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154464750 staywilliam A April 22, 2022, 5:54 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154434510 paul_t A April 21, 2022, 7:21 p.m. OK GNU C++17 (64) TESTS 18 0 0 800
154269050 Axire A April 21, 2022, 11:04 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154163971 HP_BenLadeN A April 20, 2022, 4:28 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154161955 saeedhayati32 A April 20, 2022, 3:51 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154161098 jagerknight A April 20, 2022, 3:34 a.m. OK GNU C++17 (64) TESTS 18 0 0 800
154837702 karthicksai2001 A April 24, 2022, 10:34 a.m. OK GNU C++17 (64) TESTS 18 15 0 800
154852908 awakenedbeast A April 24, 2022, 12:54 p.m. OK GNU C++17 (64) TESTS 18 15 0 800
154169984 chenmoooo A April 20, 2022, 6:09 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154177384 hialine A April 20, 2022, 8:03 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154199194 coderv_4503 A April 20, 2022, 1 p.m. OK GNU C++20 (64) TESTS 18 0 0 800
154231296 abdelrahman_rashed A April 20, 2022, 9:30 p.m. OK GNU C++20 (64) TESTS 18 0 0 800
154237884 sakundu A April 21, 2022, 1:23 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154258026 Abs_Shagor99 A April 21, 2022, 8:25 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154437989 A_G A April 21, 2022, 8:13 p.m. OK GNU C++20 (64) TESTS 18 0 0 800
154475634 s7win99 A April 22, 2022, 8:10 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154157384 Chao_zi A April 20, 2022, 2:17 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154156783 nicolasalba A April 20, 2022, 2 a.m. OK GNU C++20 (64) TESTS 18 0 0 800
154156049 bernborgess A April 20, 2022, 1:39 a.m. OK Haskell TESTS 18 31 0 800
154901063 dpzdpz A April 25, 2022, 3:40 a.m. OK Java 11 TESTS 18 170 0 800
154172954 acumen A April 20, 2022, 6:55 a.m. OK Java 11 TESTS 18 170 0 800
154168757 parth_13_ A April 20, 2022, 5:52 a.m. OK Java 11 TESTS 18 170 0 800
154168819 parth_13_ A April 20, 2022, 5:52 a.m. OK Java 11 TESTS 18 171 0 800
154623141 sf14t A April 23, 2022, 6:19 a.m. OK Java 11 TESTS 18 171 0 800
154286001 suchit_07 A April 21, 2022, 2:25 p.m. OK Java 11 TESTS 18 171 0 800
154165716 dhruvil_8803 A April 20, 2022, 4:59 a.m. OK Java 11 TESTS 18 171 0 800
154153587 Tier33 A April 20, 2022, 12:32 a.m. OK Java 11 TESTS 18 171 0 800
154152048 the_unseen A April 19, 2022, 11:43 p.m. OK Java 11 TESTS 18 171 0 800
154210170 mahmoud_hosam A April 20, 2022, 3:16 p.m. OK Java 11 TESTS 18 186 0 800
154391560 harshitnsharma A April 21, 2022, 3:55 p.m. OK Java 8 TESTS 18 93 0 800
154213017 DEMO23 A April 20, 2022, 3:54 p.m. OK Java 8 TESTS 18 93 0 800
154187877 ND_ A April 20, 2022, 10:38 a.m. OK Java 8 TESTS 18 93 0 800
154449944 O_E A April 22, 2022, 12:54 a.m. OK Java 8 TESTS 18 108 0 800
154277143 dev_14 A April 21, 2022, 12:54 p.m. OK Java 8 TESTS 18 108 0 800
154169143 roctes7 A April 20, 2022, 5:57 a.m. OK Java 8 TESTS 18 108 0 800
154164608 amgi_001 A April 20, 2022, 4:40 a.m. OK Java 8 TESTS 18 108 0 800
154830784 Unrated_Pritam A April 24, 2022, 9:12 a.m. OK Java 8 TESTS 18 109 0 800
154226572 ak_ankit A April 20, 2022, 7:42 p.m. OK Java 8 TESTS 18 109 0 800
154221960 BhargavModha A April 20, 2022, 6:14 p.m. OK Java 8 TESTS 18 109 0 800
154566836 cfcfs A April 22, 2022, 4:10 p.m. OK Kotlin 1.6 TESTS 18 248 819200 800
154494719 hidk A April 22, 2022, 12:11 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154281074 mnrmustafa A April 21, 2022, 1:39 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154254739 xuancx A April 21, 2022, 7:28 a.m. OK MS C++ 2017 TESTS 18 15 0 800
154233547 visionarylad A April 20, 2022, 10:39 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154228072 Damirca A April 20, 2022, 8:15 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154205604 Killer_No.47 A April 20, 2022, 2:14 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154197419 nadoosh A April 20, 2022, 12:40 p.m. OK MS C++ 2017 TESTS 18 15 0 800
154169614 Anish_2002 A April 20, 2022, 6:04 a.m. OK MS C++ 2017 TESTS 18 15 0 800
154268448 the_killah A April 21, 2022, 10:54 a.m. OK MS C++ 2017 TESTS 18 31 0 800
154237841 sweetMilk A April 21, 2022, 1:21 a.m. OK MS C++ 2017 TESTS 18 31 0 800
154854470 ramanujanvs A April 24, 2022, 1:09 p.m. OK Node.js TESTS 18 77 1638400 800
154211210 GarikUnit A April 20, 2022, 3:30 p.m. OK PascalABC.NET TESTS 18 233 204800 800
154278319 Chiho A April 21, 2022, 1:08 p.m. OK PyPy 3 TESTS 18 93 1740800 800
154152082 hxu10 A April 19, 2022, 11:44 p.m. OK PyPy 3 TESTS 18 93 2048000 800
154168576 tahuruzzoha A April 20, 2022, 5:49 a.m. OK PyPy 3 TESTS 18 93 2150400 800
154742030 raggzy A April 23, 2022, 3:23 p.m. OK PyPy 3 TESTS 18 108 1945600 800
154207044 pmarecki A April 20, 2022, 2:32 p.m. OK PyPy 3 TESTS 18 108 1945600 800
154556657 whatshisbucket A April 22, 2022, 3:46 p.m. OK PyPy 3 TESTS 18 108 2150400 800
154275169 dogydevstorage A April 21, 2022, 12:31 p.m. OK PyPy 3 TESTS 18 109 1843200 800
154263497 fiblonaria A April 21, 2022, 9:50 a.m. OK PyPy 3 TESTS 18 109 2252800 800
154222123 grawlixes A April 20, 2022, 6:17 p.m. OK PyPy 3 TESTS 18 109 2764800 800
154175472 heyyidada A April 20, 2022, 7:32 a.m. OK PyPy 3 TESTS 18 124 2969600 800
154244594 MistaAsh A April 21, 2022, 3:50 a.m. OK PyPy 3-64 TESTS 18 62 2457600 800
154265479 Marco_Lau A April 21, 2022, 10:21 a.m. OK PyPy 3-64 TESTS 18 77 2252800 800
154151097 Icedburger A April 19, 2022, 11:10 p.m. OK PyPy 3-64 TESTS 18 77 2252800 800
154179401 Alisher_Kamolov A April 20, 2022, 8:33 a.m. OK PyPy 3-64 TESTS 18 77 2457600 800
154179348 Alisher_Kamolov A April 20, 2022, 8:32 a.m. OK PyPy 3-64 TESTS 18 77 2457600 800
154175429 MashaM A April 20, 2022, 7:32 a.m. OK PyPy 3-64 TESTS 18 77 2457600 800
154154246 wolfram_ A April 20, 2022, 12:52 a.m. OK PyPy 3-64 TESTS 18 77 2457600 800
154272740 pratyanch_jain A April 21, 2022, 11:57 a.m. OK PyPy 3-64 TESTS 18 77 2867200 800
154150707 nealzane A April 19, 2022, 10:56 p.m. OK PyPy 3-64 TESTS 18 77 2867200 800
154220831 krishnam_omar A April 20, 2022, 5:55 p.m. OK PyPy 3-64 TESTS 18 78 614400 800
154232348 OLOGY A April 20, 2022, 10 p.m. OK Python 2 TESTS 18 31 0 800
154232033 OLOGY A April 20, 2022, 9:50 p.m. OK Python 2 TESTS 18 31 0 800
154618808 m7md_3llam A April 23, 2022, 5:25 a.m. OK Python 3 TESTS 18 31 0 800
154226505 Rainmaker2627 A April 20, 2022, 7:41 p.m. OK Python 3 TESTS 18 31 0 800
154872005 anish_t A April 24, 2022, 4:05 p.m. OK Python 3 TESTS 18 46 0 800
154838984 dhruvkhatri9275 A April 24, 2022, 10:49 a.m. OK Python 3 TESTS 18 46 0 800
154655252 Kirithiv A April 23, 2022, 12:22 p.m. OK Python 3 TESTS 18 46 0 800
154619492 StepanovAlex A April 23, 2022, 5:34 a.m. OK Python 3 TESTS 18 46 0 800
154618889 tima228 A April 23, 2022, 5:26 a.m. OK Python 3 TESTS 18 46 0 800
154618708 Voldanys A April 23, 2022, 5:23 a.m. OK Python 3 TESTS 18 46 0 800
154468636 AppCrashExpress A April 22, 2022, 6:31 a.m. OK Python 3 TESTS 18 46 0 800
154420207 PratikshitSingh A April 21, 2022, 4:45 p.m. OK Python 3 TESTS 18 46 0 800
154265147 robostac A April 21, 2022, 10:15 a.m. OK Rust 2021 TESTS 18 15 0 800
154168295 Meegoo A April 20, 2022, 5:45 a.m. OK Rust 2021 TESTS 18 15 0 800

remove filters

Back to search problems