Requirement
There are n variables and m requirements. Requirements are represented as (x <= y), meaning that the xth variable must be less than or equal to the yth variable. Your task is to assign non-negative numbers smaller than 10 to each variable and then calculate the number of different assignments satisfying all requirements. Two assignments are different if and only if at least one variable is assigned to a different number in both assignments. Print your answer modulo 10^3 + 7. Input Format
View Solution →A Super Hero
Ma5termind is crazy about Action Games. He just bought a new one and got down to play it. Ma5termind usually finishes all the levels of a game very fast. But, This time however he got stuck at the very first level of this new game. Can you help him play this game. To finish the game, Ma5termind has to cross N levels. At each level of the game, Ma5termind has to face M enemies. Each enemy has its associated power P and some number of bullets B. To knock down an enemy, Ma5termind needs to shoot
View Solution →Road Maintenance
Byteland has N cities (numbered from 1 to N) and N-1 bidirectional roads. A path is comprised of 1 or more connected roads. It is guaranteed that there is a path from any city to any other city. Steven is a road maintenance worker in Byteland. He is required to maintain exactly M paths on any given workday. He cannot work on the same road twice in one day (so no 2 paths can contain the same 2 roads). Steven can start his workday in any city and, once he has finished maintaining a path, telepo
View Solution →Billboards
ADZEN is a popular advertising firm in your city that owns all n billboard locations on Main street. The city council passed a new zoning ordinance mandating that no more than k consecutive billboards may be up at any given time. For example, if there are n=3 billboards on Main street and k=1, ADZEN must remove either the middle billboard, the first two billboards, the last two billboards or the first and last billboard. Being a for-profit company, ADZEN wants to lose as little advertising re
View Solution →Beautiful Strings
You are given a string, S, consisting of lowercase English letters. A string is beautiful with respect to S if it can be derived from S by removing exactly 2 characters. Find and print the number of different strings that are beautiful with respect to S. Input Format A single string of lowercase English letters denoting S. Constraints 3 <= |S| <= 10^6 3 <= |S| <= 20 holds for test cases worth at least 15% of the problem's score. 3 <= |S| <= 2000 holds for test cases worth at l
View Solution →