Click here to load reader
Date post: | 23-Oct-2014 |
Category: |
Documents |
Upload: | ricky-hurtado |
View: | 44 times |
Download: | 0 times |
Click here to load reader
III Concurso de Preparación ACM-ICPC México Abril 2012
Analysis for problems of the competition ...
Problem-Setter: Ing. Yonny Mondelo HernándezInstitution: Universidad de las Ciencias Informáticas (CUBA)~ Contact-Mail: ymondelo @ uci.cu ~ COJ-Account: ymondelo20
Sites:Universidad Vasco de Quiroga (UVAQ)Universidad Panamericana (UP) – BonaterraBenemérita Universidad Autónoma de Puebla (BUAP)Instituto Tecnológico de Estudios Superiores (ITES) de ZamoraInstituto Tecnológico y de Estudios Superiores de Monterrey (ITESM) – Querétaro
III Concurso de Preparación ACM-ICPC México Abril 2012
Problem: 1793 - Substring Changes
Two cases for check... consider the sample
T = "ACM" and E = "ICPC".
1 - You hold the first letter of T, with every position of E,
and check with S finishing with the last valid intersection
between T and E.
2 - You hold the first letter of E, with every position of T,
and similarly check with S finishing the last valid
Intersection between T and E.
III Concurso de Preparación ACM-ICPC México Abril 2012
Problem: 1793 - Substring Changes
For the sample there are 6 cases:
ACM---
--ICPC
ACM--
-ICPC
ACM-
ICPC
-ACM
ICPC
--ACM
ICPC-
---ACM
ICPC--
Need 4 changes...
Need 4 changes...
Need 3 changes...
Need 4 changes...
Need 4 changes...
Need 3 changes...
III Concurso de Preparación ACM-ICPC México Abril 2012
1794 - Who Committed the Crime
We call people who said the suspect committed a murder
accused and the people who say suspect did not commit
murder justifying. Consider the number of suspected k.
Suppose that he had committed murder, and calculate
how much time people have told the truth. People who
have told the truth - these are people who accused him,
and the people who did not justify it.
Thus, their number is:
III Concurso de Preparación ACM-ICPC México Abril 2012
1794 - Who Committed the Crime
The number of people who have accused him, plus the
number of people who are acquitted anyone, and minus the
number of people who are acquitted him. After these steps,
in O(1) calculate for each suspect the number of people who
speak the truth in that, if he was a criminal, and this number
is m, then this person may be the culprit. And once we have
found a list of possible offenders, then it is easy for each
person to determine whether he could tell the truth or not.
III Concurso de Preparación ACM-ICPC México Abril 2012
1795 - Dealing with the K-th Pair of Elements
To begin with, I want to note that this problem has caused
multiple questions, although the subject was clearly and
unambiguously says what to do.
First sort the array S. If all the numbers are different, then
the obvious answer - a pair (S [k / n], S [k % n]), where
the operation % means the remainder of the module.
III Concurso de Preparación ACM-ICPC México Abril 2012
1795 - Dealing with the K-th Pair of Elements
However, if the array is a duplicate of, then the situation
becomes a bit trickier, consider an example: let the data
array (1, 1, 2, 2), then the pair recorded as follows:
(1, 1), (1, 1), ( 1, 1), (1, 1), (1, 2), (1, 2), (1, 2), (1, 2),
(2, 1), (2, 1), (2, 1), (2, 1), (2, 2), (2, 2), (2, 2), (2, 2),
each pair is taken into account and is not going away,
always treated exactly n^2 pairs of numbers.
III Concurso de Preparación ACM-ICPC México Abril 2012
1795 - Dealing with the K-th Pair of Elements
What can I do in this case ?
III Concurso de Preparación ACM-ICPC México Abril 2012
1795 - Dealing with the K-th Pair of Elements
It is still true that the first number - this is S [k / n].
A second number - this is S [(k-n · cnt) / num], where cnt:
- number of elements in the array is strictly smaller than
S [k / n], and the num: - number of elements in the array,
which is equal to S [k / n].
This formula is easy to see by considering a few examples
of repetitive elements. In a pinch, you can write a trivial
solution for the O (n^2·log(n)) and make sure that you
have correctly come up with a formula.
III Concurso de Preparación ACM-ICPC México Abril 2012
1800 - Maximum Subset of Array
You count the number of positive numbers, negative
numbers and zeros.
- IF there are positive numbers, the maximum sum
will be the sum of all positive numbers. - Else IF there
are at least one zero, the maximum sum will be 0.
- Other case, the maximum sum will be the max number.
But, what with the count of possible solutions???
Well, you only should thinks about the number of zeros :)
III Concurso de Preparación ACM-ICPC México Abril 2012
1801 - ASCII Area
Scan the picture top-to-bottom, or left-to right...
--- Count the number of "\" and "/":
◦ If even, we're outside the polygon
◦ If odd, we're inside the polygon
Area = (number of "\" and "/") / 2 + number of "." inside...
III Concurso de Preparación ACM-ICPC México Abril 2012
1802 - Binary Encoding
- Find the smallest n, such that: m <= 2^n
- Now k = 2^n – m, is the number of “unused”
codes compared to binary encoding
◦ k is exactly the max number of codes with n-1 bits
So, to get the answer write
◦ For i in [0, k-1] write binary encoding of i with n-1 bits.
◦ For i in [k, m-1] write binary encoding of (i + k) with n bits.
III Concurso de Preparación ACM-ICPC México Abril 2012
1803 - The Grille
Pretty easy, wasn’t it?
III Concurso de Preparación ACM-ICPC México Abril 2012
1804 - Stack Machine Executor
Straightforward Simulation.
Beware of Integer Overflow (MUL).
III Concurso de Preparación ACM-ICPC México Abril 2012
Analysis for problems of the competition ...
Problem-Setter: Ing. Yonny Mondelo HernándezInstitution: Universidad de las Ciencias Informáticas (CUBA)~ Contact-Mail: ymondelo @ uci.cu ~ COJ-Account: ymondelo20
Sites:Universidad Vasco de Quiroga (UVAQ)Universidad Panamericana (UP) – BonaterraBenemérita Universidad Autónoma de Puebla (BUAP)Instituto Tecnológico de Estudios Superiores (ITES) de ZamoraInstituto Tecnológico y de Estudios Superiores de Monterrey (ITESM) – Querétaro