Here you can find solution (on python
) to all problems for
[Yandex Training 3.0]
File template.py
is designed so you don't have to worry about input and output speed
(this is done automatically as fast as possible).
Yes, in some tasks this is important...
Top of my conclusions on this context:
-
input/output
is an indispensable part of the task; you need to think about how fast you read and write data; that's what I wrote thetemplate.py
to combat this problem (it is an adoptation of@Slamur
s [template]) -
the problem's input limits are the most important information in the problem's condition; you can use them to figure out the asymptotic required solution (assume that
python
can handle10^7
operations; then an * n
solution with an input complexity of10 000
is not even worth writing, whilen * logn
is fine) -
even simple arithmetic operations can be saved (for example, if suddenly within a loop you repeatedly step to elements at some distance, for example
d * * 3
, then by storing this value at each iteration in theshift
variable, you can significantly speed up the program
- iterating over rows and columns in a matrix, if they are represented by a list
of lists, is not the same thing; (yes, this is quite a basic rule,
but once in an asymptotically optimal solution I ran into this,
and for a long time I could not understand what solution the authors of the
problem expected from me... the reason for this phenomenon is the physical
arrangement of array memory elements and
random access
speed)