原題: any new buildings are under construction on the campus of the University of Waterloo. The university has hired bricklayers, electricians, plumbers, and a computer programmer. A computer programmer? Yes, you have been hired to ensure that each
原題: Along a circular track, there are N gas stations, which are numbered clockwise from 1 up to N. At station i, there are p i gallons of petrol available. To race from station i to its clockwise neighbor one need q i gallons of petrol. Consider
原題: The headmaster of Spring Field School is considering employing some new teachers for certain subjects. There are a number of teachers applying for the posts. Each teacher is able to teach one or more subjects. The headmaster wants to select
原題: E. Swapping Characters time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k
原題: Walking on the Safe Side Square City is a very easy place for people to walk around. The two-way streets run North-South or East-West dividing the city into regular blocks. Most street intersections are safe for pedestrians to cross. In some