Skip to content

Files

Latest commit

865aaef · Jul 13, 2018

History

History

1-Introduction

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 13, 2018

Resources

  • Competitive Programming Chapter 1
  • Competitive Programmer's Handbook page 3 to 21

Questions

part one:

  1. Insomnia cure
  2. Anton and Letters
  3. Taxi
  4. Rank List
  5. Rock, Scissors, Paper

part two:

  1. Lovely Palindromes
  2. Guess the Permutation
  3. New Year's Eve
  4. Plate Game
  5. Traffic Lights

Editorial

part one:

  1. see part 148A - Insomnia cure in this editorial
  2. see part 443A - Anton and Letters in this editorial
  3. see part B 158B - Taxi in this editorial
  4. see part 166A - Rank List in this editorial
  5. see part Rock, Scissors, Paper this editorial. also see code

part two:

  1. see part 688B: Lovely Palindromes in this editorial
  2. see part Guess the Permutation in this editorial
  3. see part 912B - New Year's Eve in this editorial
  4. see part 197A - Plate Game in this editorial
  5. see part Traffic Lights in this section
Traffic Lights

You should search over all 5 hours (18000 seconds) to find a second which all of the traffic lights show green simultaneously. For every input x, we know that its light cycle is 2x seconds and its green period is between start of the cycle and x-5 (after x- 5 seconds, the light turns orange) Notice that you should start searching from one second after the first light turns red, due to assumption of the question. For exmaple for the first test case, start searching from second 20 (19+1) which first light has turned red , you wil find that in second 40 both of the lights are green.

see code

For more questions in this topic see codeforces questions with constructive algorithms and implementation tags.