0w1

Entries from 2018-01-01 to 1 year

SRM 630 Div2

SRM

Easy. DoubleLetterProblem Description: You are given a string S. Each time you can choose two consecutive letters that are identical, and remove them. After removal, both sides are connected, i.e., the result still remains to be a string. …

SRM 673 Div2

SRM

Easy. BearSongProblem Description: Given an array with N elements, count number of elements that appeared exactly once.Constraints: 1 ≤ N ≤ 50 1 ≤ A[i] ≤ 1000Solution: FunctionalCode: class BearSong { public: int countRareNotes(std::vector<int></int>…

SRM 679 Div2

SRM

Easy. ListeningSongsProblem Description: There are two playlists. A playlist consists of some songs, each described by the units of time it takes. You have listen to at least T songs from each playlist. Given that you have at most minutes …

SRM 687 Div2

SRM

Easy. Quorum:Problem Description: You are given N elements. Find the sum of the minimum K elements.Constraints: 1 ≤ K ≤ N ≤ 50Solution: Sort and greedy.Code: class Quorum { public: int count(std::vector<int> arr, int k) { std::sort(arr.begin(),</int>…

SRM 700 Div2

SRM

Easy. Xylophone:Code: class Xylophone { public: int countKeys(std::vector<int> keys) { std::set<int> bag; for (int v : keys) bag.emplace(v % 7); return bag.size(); } }; Medium. XMarksTheSpot:Problem Description: You are given a 2D board. There are t</int></int>…

SRM 701 Div2

SRM

Easy. SquareFreeString:Problem Description: Given a string, determine whether there is a substring that is squared (e.g., ww).Constraints: s.size ≤ 50Solution: O(s.size ** 4)Code: class SquareFreeString { public: std::string isSquareFree(s…

SRM 702 Div2

SRM

Easy. TestTaking:Problem Description: There are q false/true questions, in which you guessed g are true, and there are a that are really true. Output the maximum number of questions you might get correct.Constraints: 1 ≤ Q ≤ 50Solution: As…

SRM 710 Div2

SRM

Easy. MagicSubset:Problem Description: There are N stones with some weight. The first stone is magical, and if you choose it, each stone will have its weight multiplied by -1. Output the maximum weight sum you can obtain.Constraints: 1 ≤ N…

POJ 3678 Katu Puzzle

Problem Description: Given some constraints formed with two variables, and operator of OR, AND, or XOR, you are to find whether there exists a solution to satisfy all the constraints.Constraints: 1 ≤ N ≤ 1000 (number of variables) 1 ≤ M ≤ …

POJ 3537 Crosses and Crosses

Problem Description: Two players take turn in playing a game on a 1 x N board. When it is a player's turn, he puts a marker on a grid that had no marker. If after a movement there are 3 consecutive markers on the board, the player who made…

POJ 1740 A New Stone Game

Problem Description: There are N piles of stones, each with no more than 100 stones. Two players play this game, when it is one's turn, one should: Select a non-empty pile, remove at least one stone, then take arbitrary number of stones fr…