Editorial for COCI '08 Regional #1 Nop


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Examine the program sequentially from left to right. If an instruction (capital letter) is at an address not divisible by 4, then we need to add NOP instructions just before it until the address becomes divisible by 4.

It is possible to literally add characters into the program string, but not necessary. It suffices to keep track of the number of inserted NOP instructions; the actual address of any instruction is its original address plus the number of NOP instructions inserted before it.


Comments

There are no comments at the moment.