## [Solution] Mainak and the Bleeding Polygon solution codeforces

Mainak and the Bleeding Polygon solution codeforces – Mainak has a convex polygon P with 𝑛n vertices labelled as 𝐴1,𝐴2,…,𝐴𝑛A1,A2,…,An in a counter-clockwise fashion. [Solution] Mainak and the Bleeding Polygon solution codeforces The coordinates of the 𝑖i-th point 𝐴𝑖Ai are given by (𝑥𝑖,𝑦𝑖)(xi,yi), where 𝑥𝑖xi and 𝑦𝑖yi are both integers. Further, it is known that the interior angle at 𝐴𝑖Ai is either a right angle or a proper obtuse angle. … Read more

## [Solution] A Certain Magical Party solution codeforces

A Certain Magical Party solution codeforces – There are 𝑛n people at a party. The 𝑖i-th person has an amount of happiness 𝑎𝑖ai. [Solution] A Certain Magical Party solution codeforces Every person has a certain kind of personality which can be represented as a binary integer 𝑏b. If 𝑏=0b=0, it means the happiness of the person will increase if he … Read more

## [Solution] Late For Work solution codeforces

Late For Work solution codeforces – Debajyoti has a very important meeting to attend and he is already very late. Harsh, his driver, needs to take Debajyoti to the destination for the meeting as fast as possible. [Solution] Late For Work solution codeforces Harsh needs to pick up Debajyoti from his home and take him … Read more

## [Solution] Almost Perfect solution codeforces

Almost Perfect solution codeforces – A permutation 𝑝p of length 𝑛n is called almost perfect if for all integer 1≤𝑖≤𝑛1≤i≤n, it holds that |𝑝𝑖−𝑝−1𝑖|≤1|pi−pi−1|≤1, where 𝑝−1p−1 is the inverse permutation of 𝑝p (i.e. 𝑝−1𝑘1=𝑘2pk1−1=k2 if and only if 𝑝𝑘2=𝑘1pk2=k1). [Solution] Almost Perfect solution codeforces Count the number of almost perfect permutations of length 𝑛n modulo 998244353998244353. Input The first line contains a single integer 𝑡t (1≤𝑡≤10001≤t≤1000) — the number of test cases. The description of each … Read more

## [Solution] Edge Split solution codeforces

Edge Split solution codeforces – You are given a connected, undirected and unweighted graph with 𝑛n vertices and 𝑚m edges. Notice the limit on the number of edges: 𝑚≤𝑛+2m≤n+2. [Solution] Edge Split solution codeforces Let’s say we color some of the edges red and the remaining edges blue. Now consider only the red edges and count the number of connected … Read more

## [Solution] Jatayu’s Balanced Bracket Sequence solution codeforces

Jatayu’s Balanced Bracket Sequence solution codeforces – Last summer, Feluda gifted Lalmohan-Babu a balanced bracket sequence 𝑠s of length 2𝑛2n. [Solution] Jatayu’s Balanced Bracket Sequence solution codeforces Topshe was bored during his summer vacations, and hence he decided to draw an undirected graph of 2𝑛2n vertices using the balanced bracket sequence 𝑠s. For any two distinct vertices 𝑖i and 𝑗j (1≤𝑖<𝑗≤2𝑛1≤i<j≤2n), Topshe draws an edge (undirected and … Read more

## [Solution] Mainak and Interesting Sequence solution codeforces

Mainak and Interesting Sequence solution codeforces – Mainak has two positive integers 𝑛n and 𝑚m. [Solution] Mainak and Interesting Sequence solution codeforces Mainak finds a sequence 𝑎1,𝑎2,…,𝑎𝑛a1,a2,…,an of 𝑛n positive integers interesting, if for all integers 𝑖i (1≤𝑖≤𝑛1≤i≤n), the bitwise XOR of all elements in 𝑎a which are strictly less than 𝑎𝑖ai is 00. Formally if 𝑝𝑖pi is the bitwise XOR of all elements in 𝑎a which are strictly less than 𝑎𝑖ai, then 𝑎a is an interesting sequence if 𝑝1=𝑝2=…=𝑝𝑛=0p1=p2=…=pn=0. For example, sequences [1,3,2,3,1,2,3][1,3,2,3,1,2,3], [4,4,4,4][4,4,4,4],  are interesting, whereas [1,2,3,4][1,2,3,4] (𝑝2=1≠0p2=1≠0), [4,1,1,2,4][4,1,1,2,4] (𝑝1=1⊕1⊕2=2≠0p1=1⊕1⊕2=2≠0), [29,30,30][29,30,30] (𝑝2=29≠0p2=29≠0) aren’t … Read more

## [Solution] Mainak and Array solution codeforces

Mainak and Array solution codeforces – Mainak has an array 𝑎1,𝑎2,…,𝑎𝑛a1,a2,…,an of 𝑛n positive integers. He will do the following operation to this array exactly once: Pick a subsegment of this array and cyclically rotate it by any amount. [Solution] Mainak and Array solution codeforces Formally, he can do the following exactly once: Pick two integers 𝑙l and 𝑟r, such that 1≤𝑙≤𝑟≤𝑛1≤l≤r≤n, and … Read more

## [Solution] Meeting Rooms III solution leetcode

[Solution] Meeting Rooms III solution leetcode Meeting Rooms III solution leetcode – You are given an integer n. There are n rooms numbered from 0 to n – 1. You are given a 2D integer array meetings where meetings[i] = [starti, endi] means that a meeting will be held during the half-closed time interval [starti, endi). All the values of starti are unique. [Solution] Meeting Rooms III solution leetcode Meetings … Read more

## [Solution] Longest Nice Subarray solution leetcode

[Solution] Longest Nice Subarray solution leetcode Longest Nice Subarray solution leetcode – You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0. Return the length of the longest nice subarray. A subarray is a contiguous part of an array. Note that subarrays of length 1 are always considered … Read more