[Solution] Qingshan Loves Strings 2 Solution Codeforces

[Solution] Qingshan Loves Strings 2 Solution Codeforces time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Qingshan has a string s� which only contains 00 and 11. A string a� of length k� is good if and only if ai≠ak−i+1��≠��−�+1 for all i=1,2,…,k�=1,2,…,�. For Div. 2 contestants, note that this condition is different from the condition in … Read more

 [Solution] Subarrays Distinct Element Sum of Squares I Solution Leetcode

Subarrays Distinct Element Sum of Squares I Solution Leetcode User Accepted:0 User Tried:0 Total Accepted:0 Total Submissions:0 Difficulty:Easy You are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the … Read more

Subarrays Distinct Element Sum of Squares II Solution Leetcode

Subarrays Distinct Element Sum of Squares II Solution Leetcode User Accepted:0 User Tried:0 Total Accepted:0 Total Submissions:0 Difficulty:Hard You are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the … Read more

[solution] Reaper Reaps solution codechef

Problem solution codechef I have no compassion, I only exist to collect the souls of the living. On Halloween, Grim Reaper wants to reap souls from houses. There are �N houses. The �i-th of them has a safety level of ��Ai​ and has ��Bi​ people living in it. The Reaper has an ability level, denoted �L. Initially, �=0L=0. When the Reaper visits a house, the following … Read more

[solution] Ghoul-icious Goodies solution codechef

Problem solution codechef Despite my ghoulish reputation, I really have the heart of a small boy. I keep it in a jar on my desk. Alice wants to give Bob some goodies, but she’s uncertain about how many to give. To help determine the quantity, she presented Bob with the following challenge: Alice has a … Read more

[solution] Spooky Sequences solution codechef

Problem solution codechef “I am not a witch. I’m your wife.” – Valerie, The Princess Bride Once upon a time, in a distant land, a mischievous witch spied on a group of people who were enjoying their time together. Enveloped by a dark desire, she resolved to put an end to their merry gatherings and … Read more

[solution] Wishcraft solution codechef

Problem solution codechef Magic is really very simple, all you’ve got to do is want something and then let yourself have it. Chadda and his Wizard friend PSC were exploring the enchanted forest on Halloween, when Chadda stumbled upon an array �A of �N magical numbers which took him into a different world. Chadda remembered that PSC gave him … Read more

[solution] Dull Operation solution codechef

Problem solution codechef Be afraid, be very afraid. On Halloween, Chef is in a somber mood. Chef has an odd integer �N that he has to decode. To do so, Chef would like to find a pair of integers �x and �y (0≤�,�<2300≤x,y<230) such that: (�∣�)⋅(�⊕�)=�(x∣y)⋅(x⊕y)=N Help Chef find any such pair! It can be proved that a valid pair always exists. Here, ∣∣ represents the bitwise OR operation, … Read more

[soilution] Take it Easy solution codechef

Problem solution codechef Believe nothing you hear, and only one half that you see On a Halloween evening, young Tim embarks on a candy-filled quest with his friends, dressed as ghouls and witches. There are �N friends, initially the �i-th of them has ��Ai​ candies. To truly savor the spooky spirit, Tim wishes for everyone to have an equal number of candies. … Read more

[solution] Dracula Eats solution codechef

Problem solution codechef Eat, drink, and be scary There are �N spooky days left until Halloween. Dracula dines at a mysterious restaurant that changes its spooky menu daily. He particularly enjoys what they serve on Tuesday. Today is Monday, so he wishes to calculate how many times he can indulge in his favourite menu in the next �N days (including … Read more