Monthly Archives: May 2022
Educational Codeforces Round 129 – Problem C
You are given two arrays a and b, both consisting of n integers. In one move, you can choose two indices i and j (1≤i,j≤n; i≠j) and swap ai with aj and bi with bj. You have to perform the swap in both arrays. You are allowed to perform at most 104 moves (possibly, zero)….
Educational Codeforces Round 129 – Problem B
Monocarp has just learned a new card trick, and can’t wait to present it to you. He shows you the entire deck of n cards. You see that the values of cards from the topmost to the bottommost are integers a1,a2,…,an, and all values are different. Then he asks you to shuffle the deck m…
Educational Codeforces Round 129 – Problem A
Alice and Bob play a game. Alice has n cards, the i-th of them has the integer ai written on it. Bob has m cards, the j-th of them has the integer bj written on it. On the first turn of the game, the first player chooses one of his/her cards and puts it on…
Codeforces Round #793 – Problem C
C. LIS or Reverse LIS? time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You are given an array a of n positive integers. Let LIS(a) denote the length of longest strictly increasing subsequence of a. For example, LIS([2,1,1,3]) = 2. LIS([3,5,10,20]) = 4. LIS([3,1,2,4]) =…
Codeforces Round #793 – Problem B
B. AND Sorting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You are given a permutation p of integers from 0 to n−1 (each of them occurs exactly once). Initially, the permutation is not sorted (that is, pi>pi+1 for at least one 1≤i≤n−1). The permutation…
Codeforces Round #793 – Problem A
A. Palindromic Indices time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You are given a palindromic string s of length n. You have to count the number of indices i (1≤i≤n) such that the string after removing si from s still remains a palindrome. For…