## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Rules: 1. There are nine problems to be completed in four hours. 2. All problems require you to read the test data from standard input and write results to standard output. You cannot use files for output. Additional input and output specifications can be found in the General Information Sheet. The allowed programming languages are C, C++ and Java. 3. All programs will be re-compiled prior to testing with the judges’ data. Nonstandard libraries cannot be used in your solutions. The Standard Template Library (STL) and C++ string libraries are allowed. The standard Java API is available, except for those packages that are deemed dangerous by contest officials (e.g., that might generate a security violation). The Standard Pascal Libraries are allowed. 4. A team’s score is based on the number of problems they solve and penalty points, which reflect the amount of time and number of incorrect submissions made before the problem is solved. For each problem solved correctly, penalty points are charged equal to the time at which the problem was solved plus 20 minutes for each incorrect submission. No penalty points are added for problems that are never solved. Teams are ranked first by the number of problems solved and then by the fewest penalty points. 5. Programming style is not considered in this contest. You are free to code in whatever style you prefer. 6. Documentation is not required. 7. All communication with the judges will be handled by email and messenger, acmjudge1@hotmail.com. acmjudge2@hotmail.com, acmjudge3@hotmail.com. 8. Judges’ decisions are to be considered final. No cheating will be tolerated. 9. Good Luck, and HAVE FUN!!!

Problem A Delta Encoding and Decoding Input File: A.IN Output File: standard output Program Source File: A.C or A.CPP or A.JAVA A very simple encryption scheme which represents a big improvement over a substitution cipher is a delta cipher. Here’s how it works: The letters A through Z are given a numerical values starting with 0 and ending with 25. These values aren’t necessarily given in that order, but the mapping is one to one. (The trivial mapping where A has value 0, B has value 1, etc. is the default cipher. It’s what you use when you don’t have anything better.) In order to encrypt a message, the differences between successive values are used. 1. All characters except letters are transferred to the encrypted message unchanged. 2. When one letter is preceeded by something other than a letter, it is treated as though it had been preceeded by an A. 3. Case both does and does not matter in this encryption scheme. If a letter is originally uppercase, the encrypted version should be uppercase. If it is lowercase, the encrypted version should be lowercase. However, A and a are the same letter. 4. When one letter is preceeded by another, the difference between the two values is the value of the first is subtracted from the second. The letter whose value is equivalent to this difference modulo 26 will replace the second letter in the new text. The input is merely a sequence of a commands, one per line, and is terminated by an EOF. No line contains more than 10000 characters. There are three command words: ENCRYPT, DECRYPT, and CIPHER. The case of the letters in these words is not important, and each word will be followed by at least one space. Any line which begins with any word other than one of these three commands requires the response “Command not understood.” The ENCRYPT and DECRYPT commands are self-explanatory. The encrypt command is followed by plain text which needs to be encrypted and the decrypt command is followed by encrypted text which must be put into plain text. Whatever follows one of these two command words should be either encrypted or decrypted using the current cipher. If no cipher has yet been given, you should use the default cipher. The CIPHER command should be followed by the twenty-six letters of the alphabet. The order of these letters is important and that order determines the value for each character — thefirst letter has value 0; the second letter has value 1; etc. There may be spaces and punctuation; these should be ignored; however, this line must have exactly twenty-six letters on it with no repetitions. Any problem requires the response, “Bad cipher. Using default.” (And, as indicated, you should actually use the default). If the cipher is understandable, you need to echo it back to the user as shown below, and then use it for all subsequent commands.

Sample Input:

ENCRYPT The quick brown fox leaped CIPHER qwertyuiopasdfghjklzxcvbnm ENCRYPT The quick brown fox leaped DECRYPT Xsf juwgv fuyzb rcd oaomza ENCRIPT This won't work! CIPHER qAZwSXedCRfv tgbyhnujmikolp ENCRYPT The quick brown fox leaped DECRYPT Vsh puwgb gibeb rgc ocilda CIPHER qwertyuopasdfghjklzxcvbnm ENCRYPT The quick brown fox leaped DECRYPT Tox qeoui bqxir fjj ltwppz over the lazy dog. over the lazy dog. nguw xsf olpd evu. over the lazy dog. kbiw vsh owag ehh. over the lazy dog. ohjn tox lpzz dls.

Sample Output:

RESULT: Tox qeoui bqxir fjj ltwppz ohjn tox lpzz Good cipher. Using QWERTYUIOPASDFGHJKLZXCVBNM. RESULT: Xsf juwgv fuyzb rcd oaomza nguw xsf olpd RESULT: The quick brown fox leaped over the lazy Command not understood. Good cipher. Using QAZWSXEDCRFVTGBYHNUJMIKOLP. RESULT: Vsh puwgb gibeb rgc ocilda kbiw vsh owag RESULT: The quick brown fox leaped over the lazy Bad cipher. Using default. RESULT: Tox qeoui bqxir fjj ltwppz ohjn tox lpzz RESULT: The quick brown fox leaped over the lazy dls. evu. dog. ehh. dog. dls. dog.

Problem B Hidden Password Input File: B.IN Output File: standard output Program Source File: B.C or B.CPP or B.JAVA Some time the programmers have very strange ways to hide their passwords. See for example how Billy “Hacker” Geits hide his password. Billy chooses a string S composed of small Latin letters with length L. Then he makes all L-1 one-letter left cyclic shifts of the string and takes as a password one prefix of the lexicographically first of the obtained strings (including S). For example let consider the string alabala. The cyclic one-letter left shifts (including the initial string) are: alabala labalaa abalaal balaala alaalab laalaba aalabal and lexicographically first of them is the string aalabal. The first letter of this string is in position 6 in the initial string (the positions in the string are counted from 0). Write a program that for given string S finds the start position of the smallest lexicographically one-letter left cyclic shift of this string. If the smallest lexicographically left shift appears more than once then the program have to output the smallest initial position. Your program has to be ready to solve more than one test case. The first line of the input file will contains only the number T of the test cases. Each of the following T lines will describe one test case – first the length L of the string (5≤L≤100000) and then, separated by one space, the string S itself. The output file have to contain exactly T lines with a single number each – the initial position found by your program. EXAMPLE

Problem C Crazy tea party Input File: C.IN Output File: standard output Program Source File: C.C or C.CPP or C.JAVA n participants of «crazy tea party» sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to sit in reverse order (so that left neighbors would become right, and right – left). Input. The first line is the amount of tests. Each next line contains one integer n (1 ≤ n ≤ 32767) – the amount of crazy tea participants. Output. For each number n of participants to crazy tea party print on the standard output, on a separate line, the minimum time required for all participants to sit in reverse order. Sample Input 3 4 5 6 Sample Output 2 4 6

Problem D Supermarket Input File: D.IN Output File: standard output Program Source File: D.C or D.CPP or D.JAVA A supermarket has a set Prod of products on sale. It earns a profit px for each product xεProd sold by a deadline dx that is measured as an integral number of time units starting from the moment the sale begins. Each product takes precisely one unit of time for being sold. A selling schedule is an ordered subset of products Sell Prod such that the selling of each product xεSell, according to the ordering of Sell, completes before the deadline dx or just when dx expires. The profit of the selling schedule is Profit(Sell)= ΣxεSell px . An optimal selling schedule is a schedule with a maximum profit. For example, consider the products Prod={a,b,c,d} with (pa,da)=(50,2), (pb,db)=(10,1), (pc,dc)=(20,2), and (pd,dd)=(30,1). The possible selling schedules are listed in table 1. For instance, the schedule Sell={d,a} shows that the selling of product d starts at time 0 and ends at time 1, while the selling of product a starts at time 1 and ends at time 2. Each of these products is sold by its deadline. Sell is the optimal schedule and its profit is 80.

Write a program that reads sets of products from an input text file and computes the profit of an optimal selling schedule for each set of products. A set of products starts with an integer 0≤n≤10000, which is the number of products in the set, and continues with n pairs pi di of integers, 1≤pi≤10000 and 1≤di≤10000, that designate the profit and the selling deadline of the i-th product. White spaces can occur freely in input. Input data terminate with an end of file and are guaranteed correct. For each set of products, the program prints on the standard output the profit of an optimal selling schedule for the set. Each result is printed from the beginning of a separate line.

The input in table 2 contains two product sets. The first set encodes the products from table 1. The second set is for 7 products. The profit of an optimal schedule for these products is 185.

Problem E Lord of the Ring Input File: E.IN Output File: standard output Program Source File: E.C or E.CPP or E.JAVA Frodo must accomplish a noble and difficult mission, he must destroy a magic and wicked ring. In this quest, he must travel to a dangerous place called Modor and throw the ring into a crevice of fire. He has left home for some time and is currently following a straight and quite long road that has bushes from place to place. Being very tired Frodo thinks he would better have some rest. The only safe place along the road is a bush the position of which can be computed using a magic formula that uses the value P that is the product of the distances betwee n pairs of adjacent bushes along the road. Unfortunately what Frodo knows are only the distances between every pair of bushes along the road and the magic formula, but he doesn't know the value of P. Can you help him in this respect? The program input is from a text file. Each data set in the file stands for a particular set of distances between pairs of bushes on the road Frodo is traveling along. Each data set starts with the number of distances followed by the distances in nondecreasing order. White spaces can occur freely in the input. For each set of data the program computes the value of P to the standard output from the beginning of a separate line. If P cannot be computed from the data set the output is "No solution". It is known that there are at least two bushes and at most 1000 bushes along the road. Moreover, the value of P cannot exceed 109.

In figure 1 the second data does not accept a solution. The bush positions along the road cannot be deduced from the data and therefore the distances between adjacent points cannot be computed.

Problem F Common Subsequence Input File: F.IN Output File: standard output Program Source File: F.C or F.CPP or F.JAVA A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence <i1, i2, ..., ik> of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = <a, b, f, c> is a subsequence of X = <a, b, c, f, b, c> with index sequence <1, 2, 4, 6>. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y. The program input is from a text file. Each data set in the file contains two strings representing the given sequences. The sequences are separated by any number of white spaces. The input data are correct. For each set of data the program prints on the standard output the length of the maximum-length common subsequence from the beginning of a separate line.

Problem G Power Network Input File: G.IN Output File: standard output Program Source File: G.C or G.CPP or G.JAVA or G.PAS A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u)≥0 of power, may produce an amount 0≤p(u)≤pmax(u) of power, may consume an amount 0≤c(u)≤min(s(u), cmax(u)) of power, and may deliver an amount d(u)=s(u)+p(u)-c(u) of power. The following restrictions apply: c(u)=0 for any power station, p(u)=0 for any consumer, and p(u)=c(u)=0 for any dispatcher. There is at most one power transport line (u,v) from a node u to a node v in the net; it transports an amount 0≤l(u,v)≤lmax(u,v) of power delivered by u to v. Let Con= Σu c(u) be the power consumed in the net. The problem is to compute the maximum value of Con.

An example is in figure 1. The label x/y of power station u shows that p(u)=x and pmax(u)=y. The label x/y of consumer u shows that c(u)=x and cmax(u)=y. The label x/y of power transport line (u,v) shows that l(u,v)=x and lmax(u,v)=y. The power consumed is Con=6. Notice that there are other possible states of the network but the value of Con cannot exceed 6. There are several data sets in the input text file. Each data set encodes a power network. It starts with four integers: 0≤n≤100 (nodes), 0≤np≤n (power stations), 0≤nc≤n (consumers), and 0≤m≤n2 (power transport lines). Follow m data triplets (u,v)z, where u and v are node identifiers (starting from 0) and 0≤z≤1000 is the value of lmax(u,v). Follow np doublets (u)z, where u is the identifier of a power station and 0≤z≤10000 is the value of pmax(u). The data set ends with nc doublets (u)z, where u is the identifier of a consumer and 0≤z≤10000 is the value of cmax(u). All input numbers are integers. Except the (u,v)z triplets and the (u)z doublets, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct. Table 1. Input and output simples

For each data set from the input, the program prints on the standard output the maximum amount of power that can be consumed in the corresponding network. Each result has an integral value and is printed from the beginning of a separate line. The input in table 1 contains two data sets. The first data set encodes a network with 2 nodes, power station 0 with pmax(0)=15 and consumer 1 with cmax(1)=20, and 2 power transport lines with lmax(0,1)=20 and lmax(1,0)=10. The maximum value of Con is 15. The second data set encodes the network from figure 1.

Problem H Firefighters Input File: H.IN Output File: standard output Program Source File: H.C, H.JAVA or H.CPP A mathematician kept all his documents in a file cabinet near his desk. One day a fire set out in his office and most of his works were badly damaged. Luckily, some of the equations he had solved so many years during his long career were partially preserved. Each equation contained an expression in left side and result in the right. The preserved expressions consisted of all the numbers and brackets, but unfortunately, some of the operators between them were lost in the fire. Another problem was that the results of the equations were scattered and the mathematician was not sure if a certain answer is the result of a certain expression. Your task is to help the mathematician determine if the expressions and the results he was able to save from the fire match one another. In order to do this, you are given an expression, containing the integer numbers between 1 and 999, simple mathematical operators (+, -, *, /), brackets, and question marks (?), representing the lost mathematical operators. For every expression given, your only task is to state if an expression can or cannot give the required result. In order to help you, the mathematician has chosen only expressions that have the following restrictions: 1. The expressions contain no more than 100 symbols; 2. The brackets enclose no more than 1 operator with his two operands. However, every one of these operands can be an expression in brackets; 3. The constants in the expressions have no sign, i.e. there are no negative numbers in expressions; 4. The maximum number of question marks in the expressions (the lost operators) is less or equal to 10. The calculation should be performed using the following rules: 1. The operators * and / are of higher priority than the operators + and -. Parentheses may change the priorities as usually; 2. The operators +, -, *, and / are left associative, meaning that they group from left to right. If a, b and c are numbers: 3. a*b*c = (a*b)*c, a/b/c = (a/b)/c, a/b*c = (a/b)*c, a+b+c = (a+b)+c, ab+c = (a-b)+c, etc. 4. When dividing two integers, you should ignore the decimal fraction, for example consider the following equations: 2/5=0, 9/5=1, 100/6=16. Input: The first line of the input file contains an integer N – determining the number of equations. Next 2*N lines contain the equations. One equation is defined in two lines. The first line is the expression, defining the left side of the equation; second line is an integer result, defining the right side of the equation. The input lines do not have blanks. The strings representing expressions are guaranteed to have no syntax errors. Output: For every equation in the input file, write yes or no on separate lines on the standard output. If the expression can give the result, write yes. Otherwise, if the result cannot be achieved, write no.

Sample input and output:

Problem I Binary Polynomials Input File: I.IN Output File: standard output Program Source File: I.C or I.CPP or I.JAVA Each mapping f of the set {0,1}n of n-dimensional binary vectors to {0,1} is called Boolean function of n variables and denoted by f(xn,xn-1,…,x1). For cryptography some properties of the Boolean functions are interesting. Let denote by B(n,k) the set of n-dimensional binary vectors that have k 1’s. The task is for given Boolean function f to find the number of vectors (bn,bn-1,…,b1) from B(n,k) such that f(bn,bn1,…,b1)=1. The Boolean function will be given by its (unique) polynomial modulo 2. In these polynomials the operations addition and multiplication modulo 2 are used, defined as shown in the tables of Fig. 1. In the polynomial of a function any product of m variables xi1 xi2 Κ xim could participate or not participate. So the general form of the polynomial for n variables is:

where all coefficients aj, j=0,1,…,N=2n-1, are 0’s or 1’s and if the coefficient is equal to 0 we will omit the corresponding product and if it is equal to 1 we just will omit the coefficient. For example, the polynomial of the Boolean function disjunction of 2 variables given on Fig. 2 is 0+1.x1+1.x2+1.x2x1=x1+x2+x2x1.

Your program has to be ready to solve more than one test case. The first line of the input file Hill contains only the number T of the test cases. Each of the following T lines will describe one function – first the numbers n and k separated by single space (1≤n≤18,0≤k≤n) and then, separated by one more space a string of 2n 0’s and 1’s that are the coefficients of the corresponding polynomial, ordered as in the general form of the polynomial given above. The output file have to contain T lines with a single number each – the number of vectors found by your program. EXAMPLE

- Sequences and Their Limitsuploaded byAtikah J
- TXSeries for Multiplatforms Messages and Codes Version 6.2uploaded bydeisecairo
- Punctuatorsimp.docxuploaded byanon_223627685
- Paper 18-A Novel Block Cipher Involving a Key Bunch Matrix and a Key Based Permutation and Substitutionuploaded byEditor IJACSA
- TextIOuploaded byFerry Yudhitama
- Nameuploaded byapi-19562657
- 1089-IGate Placement Paperuploaded byPavan Kumar
- Notes 5uploaded byLuis Alberto Fuentes
- tut_9uploaded byDragan Lazic
- Arithmetic 2uploaded byAshish Jain
- A Tour Through the UNIX C Compileruploaded byAndroiDPRoject
- The Grid Cipheruploaded byAlfredVeevers
- C Standard Libraryuploaded byPietro Rossi
- Tut 9uploaded byapi-3817778
- Solve Big Data Security Issuesuploaded byATS
- Understanding Cryptography Chapter3uploaded byAliXmetec
- C Programming basics.txtuploaded byAbhishek Ranjan
- hcl2uploaded byBalwinder Singh
- IGATE Placement Papers 4uploaded byTribhuwan Pant
- 4-SequenceDiagramsuploaded byKevon Michael
- COMP 206 Course Outline 2uploaded bydudrbsla7
- chipcflowuploaded bySimranjeet Singh
- Applying and Analyzing Security using Images : Steganography v.s. Steganalysisuploaded byijcsis
- Exercícios - Creating and Using Arraysuploaded byJackson Angell
- IJEART06520uploaded byerpublication
- FARID Fresheruploaded byganip007
- FBSI_1103_enuploaded byAlen Jusufovic
- IGATE Placement Papers 3uploaded byTribhuwan Pant
- c dis and advuploaded bygceramesh
- IntroC1uploaded byMukesh Kumar

- Kant 7uploaded bySamira
- 011 Redes computacionalesuploaded bySamira
- 012.2 Aspectos Avanzados en Seguridad en Redes Apendice GFDLuploaded bySamira
- Los Piratas Son Los Padresuploaded bySamira
- LibroTransdisciplinauploaded bySamira
- 012.3 Aspectos Avanzados en Seguridad en Redes Apendiceuploaded bySamira
- foucault7uploaded bySamira
- Linux Adminuploaded bySamira
- foucault5uploaded bySamira
- foucault2uploaded bySamira
- 010 Introduccion Al Desarrollo de Softwareuploaded bySamira
- LibroComplejidaduploaded bySamira
- Kant 5uploaded bySamira
- kant6uploaded bySamira
- libroIngSoftwareLibreuploaded bySamira
- 71-74-4tuploaded bySamira
- 003 Administracion avanzada del sistema operativo linuxuploaded bySamira
- 009 Ingenieria Del Softwareuploaded bySamira
- 10 Manejo Memoriauploaded bySamira
- Spamuploaded bySamira
- 008 Implatacion de sistemasuploaded bySamira
- 006 Aspectos legales V1uploaded bySamira
- 006 Aspectos legales V2uploaded bySamira
- 001 Introduccion al software libreuploaded bySamira
- SO Teo Iuploaded bySamira
- 005 Utilidades y herramientasuploaded bySamira
- Asignacion Planificacionuploaded bySamira
- 007 Bases de Datosuploaded bySamira
- 002 Sistema operativo gnu linux basicouploaded bySamira
- 10 Manejo Memoriauploaded bySamira

Read Free for 30 Days

Cancel anytime.

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading