Codeforces Round 953 C - Manhattan Permuations | Detailed Video Editorial

  Рет қаралды 1,004

AlgoChief

AlgoChief

Күн бұрын

Пікірлер: 7
@formidablechief27
@formidablechief27 3 ай бұрын
Accepted Submission Link : codeforces.com/contest/1978/submission/266004537
@hdcutz2936
@hdcutz2936 3 ай бұрын
Man seriously how u came up with this solution during contest?... Kindly tell about how u came up to the approach during videos as hints then it will be intuitive and interactive... other than this videos and qualities are gem... Kudos continue your work soon u will get recognized
@shaasshh
@shaasshh 3 ай бұрын
true, i had all of the solution on paper with no idea what to write in code it makes me feel so uselessssss....
@formidablechief27
@formidablechief27 3 ай бұрын
Okay first of all the condition for no/yes was comparitively easy to come across. The difficulty came in constructing the array I got that how we can construct the answer for max value of k, i just needed to find for other smaller values Then i started making all possible answers for n = 6 from the abs value i had got 1 2 3 4 5 6 6 5 4 3 2 1 Diff 5 3 1 1 3 5 So if my k is >= 10 I have to swap my first and last values So a[0] = n and a[n-1] = 1 and then i will try to find the remaining swaps by the decreased k in a shorter subarray Then i saw an issue arising for this case n = 6 and k = 4 My code was returning 1 2 4 3 5 6 Now since k < 10 i wont swap 1 and 6 And since k < 6 i wont swap 2 and 5 Then i realised that for n = 5, i am getting answer for k = 4 So i thought lets merge this two answers somehow For n = 5 and k = 4 i was getting 1 4 3 2 5 So k = 4 was solvable in odd length subarray So i thought, if k is less and divisible by 4, lets use odd length and not even So, i put a[n-2] = 5 And continued my loop for [1, n-3] Over here 2 and 4 got swapped and i got ans for 4 So i did this and i got correct for all even values of n Now i had to fix odd Because if i got n = 5 and k = 6, the ans was yes but k = 6 is solvable in even length subarray not odd So similarly i did Reduced size by 1 like for even Just here opposite % 4 != 0 So then after i did this i checked what output i was getting for n = 5 and n = 6 with all possible valid values of k (only those which would give yes) And they were right and so i submitted hoping it would not fail on pretest 2😂 But i was relieved once i saw running on pretest 3.
@formidablechief27
@formidablechief27 3 ай бұрын
Constructive algorithms are usually try out many testcases and make a pattern from it.
@deboshrutimukhopadhyay7925
@deboshrutimukhopadhyay7925 3 ай бұрын
could you explain why this code is not getting accepted though I went with a similar aprroach #include using namespace std; #define ll long long int main() { int t; cin >> t; while (t--) { long long n, k; cin >> n >> k; // Check if k is odd if (k % 2 != 0) { cout
@formidablechief27
@formidablechief27 3 ай бұрын
Can u send me the submission link ?
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 55 МЛН
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 4,8 МЛН
когда не обедаешь в школе // EVA mash
00:57
EVA mash
Рет қаралды 3,7 МЛН
Codeforces Round 944 (Div 4) | Video Solutions - A to G | by Viraj Chandra | TLE Eliminators
2:20:22
C. Manhattan Permutations Codeforces Round 953 (Div. 2)
20:36
Jeevan Alexen Kavalam
Рет қаралды 328
????? How To Solve Problems Like Find Permutation
14:03
Mahmoud Ayman | | محمود أيمن
Рет қаралды 4,1 М.
Codeforces Round 961 Div 2. B1. Bouquet (Easy Version)
24:10
Codeforces Round 955 A-D | Editorial with TOURIST's solutions | Detailed Explanations
1:15:11
Decipher Algorithms with Saptarshi
Рет қаралды 910
Nobody Cares About Your Coding Projects
11:02
Tariq10x
Рет қаралды 110 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Winning Codeforces Round #663 (Div. 2)
46:18
William Lin (tmwilliamlin168)
Рет қаралды 98 М.