Tải bản đầy đủ (.doc) (7 trang)

Đáp án Đề thi Tin QT (IOI) 2001

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (42.49 KB, 7 trang )

9 441 55000 Random mix of random updates and random big* queries
(1:2)
10 463 55000 Same as 9
11 474 55000 Same as 9
12 482 55000 Same as 9
13 496 60000 Same as 9
14 503 60000 Same as 9
15 509 60000 Same as 9
16 512 60000 Same as 9
17 614 60000 Same as 9
18 819 60000 Same as 9
19 1024 60000 Same as 9
20 1024 60000 Same as 9
where
S = Size of matrix
N = Total number of operations
* = big query involves area of at least S/2 x S/2 squares
random = random per competitor, but the same for all competitors
Correct programs involving operations with worst case time O(S^2)
can pass cases 1 to 4 (20 points).
Correct programs involving operations with worst case time O(S)
can pass cases 1 to 8 (40 points).
Correct programs involving operations with worst case time O((log S)^2)
and non-optimized memory usage can pass cases 1 to 16 (80 points).
Correct programs involving operations with worst case time O((log S)^2)
and optimized memory usage can pass all cases (100 points).
Programs that use "trees" in only one dimension can score better
than the simple programs.
NOTE: The input data for each test case is generated inside the checker,
rather than read from an input file.
2/Some information about task IOIWARI


Various parameters of the game (the number of the pits, the number and
distribution of the beads, and especially the rule for moves) have been
tuned
to satisfy the following requirements:
- the game is always winnable by the first player
but not easy to win in most cases
- some game instances are winnable by the first player playing by a
simple
(greedy) strategy
- efficient solution possible with reasonable resource limitations
(memory and CPU time)
- draw is possible
- the nummber of different game instances is sufficiently large for
testing.
TEST
The opponent program plays to achive maximum score differece for the
second
player.
There are 51 different initial game positions modulo rotation.
Score differeces (Bank1-Bank2)
B : Initial Game Position
O : Optimal score difference for the first player
G1: Best score difference when first player plays according to a one-
step
look-ahead greedy strategy
G2: Best score difference when first player plays according to a two-
step
look-ahead greedy strategy
R : Score difference when first player plays by random choice
Case B O G1 G2 R


1 4 4 4 2 2 2 2: 4 -6 -4 -2
2 3 4 4 3 2 2 2: 4 -6 -2 -10
3 3 4 3 4 2 2 2: 2 -8 -10 -12
4 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 2: 4 -6 -6 -8
3 3 2 4 4 2 2: 6 4 -6 -12
4 4 2 3 2 3 2: 6 2 -2 0
3 4 3 3 2 3 2: 2 2 -2 0
4 3 2 4 2 3 2: 2 0 -2 -4
3 4 2 4 2 3 2: 2 2 -2 -8
4 2 3 4 2 3 2: 6 6 -4 -4
3 3 3 4 2 3 2: 6 2 -4 -8
3 3 4 2 3 3 2: 4 2 -2 -6
3 3 3 3 3 3 2: 2 2 -2 2
The dialog between your program and the opponent program is recorded in
the
file ioiwariX.report for test case X.
3/Some information about task TWOFIVE
There are over 700 million valid words. Therfore, in computing the
number that corresponds to a word, we must avoid explicitly counting
every lexicographically preceding word. The key observation is that

the number of valid words consistent within an assignment of the first
k letters of the alphabet (i.e. A letter[k]) to a set of locations
depends on the locations occupied by these letters, but not on which
letter is assigned to each location. For example, the number of valid
words consistent with the letters A G in either of the configurations
below is the same:
Configuration 1: A B E F
C G
D
Configuration 2:
A D F G
B E
C
This is enough to permit a dynammic programming approach to succeed in
the permitted time. Indeed, we have an "untuned" 8 millisecond
solution.
20 test cases were given as 10 pairs. The first of each pair gives a
word, from which we are to compute the number, while the second asks
for the inverse computation. As a consequence, brute forse does work
for small numbers and their inverses.
The data consisted of:
3 and its inverse, "ABCDEFGHIJKLMNOPQRSVTUWXY";
20 and its inverse;
1 000 000 and its inverse;
the maximum number (701149020) and its inverse;
and seven other essentially random nine digit values.
Case T N
-
1 W 20
2 N 20

3 W 3
4 N 3
5 W 701149020 Last word in the lexicon
6 N 701149020
7 W 1000000
8 N 1000000
9 W 350574511
10 N 350574511
11 W 106407948
12 N 106407948
13 W 100000000
14 N 100000000
15 W 299925684
16 N 299925684
17 W 699509817
18 N 699509817
19 W 660689109
20 N 660689109
where
T = kind of case (W or N)
N = ordinal number
4/Some information about task SCORE
In this task, the important thing to discover somehow, is that
removal of the starting position yields a directed acyclic graph (DAG).
A depth-first search (DFS) rooted at the starting position yields a
traversal tree whose back-edges all go to the root. Using a minimax
evaluation on that tree gives an optimal strategy in a time linear
in the number of edges of the game graph.
The 20 test cases were designed by varying the path lengths, node
values,

and number of edges, such that various non-optimal strategies can be
distinguished. The test data was evaluated against random strategies,
the 1-step look-ahead greedy strategy, the 2-step look-ahead greedy
strategy, and exhaustive game-state evaluation.
5/Some information about task DOUBLE
A simple approach to solving this task is an exhaustive search over the
combined key spaces:
for each key k1
for each key k2
if E(E(p, k1), k2) = c2
exit with k1, k2
This requires in the worst case (20-bit keys) about 2^20 * 2^20 * 2 =
2^41
encryptions. Doing an optimistic 10^6 encryptions per second it would
still take more than 25 days. (It can be halved by taking E(p, k1)
outside the inner loop.)
However, double encryption, as applied in this task, provides much less
extra security than may at first seem to be the case. If the key length
is n bits for single encryption, then an exhaustive search goes through
all possible 2^n keys. Double encryption with two independent n-bit
keys
may seem to correspond to encryption with a single 2n-bit key. But
the so-called "meet-in-the-middle attack" shows that it is actually no
stronger than a single (n+1)-bit key. (For that reason, in practice,
triple encryption is used for improving security.)
The meet-in-the-middle attack works as follows. The given plain
text p is encrypted with all possible 2^n keys and the results are
stored (one way or another) in a table. Next, the given double-
encrypted
ciphertext c2 is _decrypted_ with all possible 2^n keys, and each result

is checked against the table for a "collision". Such a collision
reveals a "double key" used for encryption.
The table is best set up as a hashed dictionary, to make both store
and retrieve operations fast. The dictionary size needs to allow for
more entries than keys to avoid too many hash collissions. Sizing the
dictionary to twice the number of keys, and storing a 20-bit key and
a 128-bit encrypted message together in 20 bytes, requires 2^21 * 20 =
40MB for the dictionary. This size can be reduced to 8 MB by not
storing
the message and recomputing it from the stored key.
The ten cases have the following characteristics:
Case s T k1 k2 Comments
- -
1 1 P A 7 This case is the same as the example
2 1 R C 5 Can be solved manually with the tool
3 2 P A7 6E Can be solved by exhaustive search
4 2 C E1 8A Can be solved by exhaustive search
5 4 R A39E B760
6 4 R 893D F66B
7 4 R 9325 0000 Extreme key at one end of key space
8 5 C CB053 7F0F9
9 5 P A7000 6E000 Same answer as case 3
10 5 P 59D04 FFFFF Extreme key at other end of key space
where
s = number of relevant hexadecimal key digits (task input)
T = type of plaintext/ciphertext:
P for structured plaintext (random-looking ciphertext)
C for structured ciphertext (random-looking plaintext)
R for random plaintext/ciphertext
k1 = first key (task output)

k2 = second key (task output)
NOTES
All answers can easily be verified by the interactive tool that was
provided.
All possible key digits 0 F appear in the keys, including duplicates.
Structure in the plaintext or ciphertext cannot be exploited.
Cases with s=4 can be solved by exhaustive search, but each takes more
than one hour. Because these three cases have the same plaintext, they
can be attacked together with exhaustive search, to solve three cases
for the price of one case plus a little bit. Even a straightforward
implementation of the meet-in-the-middle-attack works in seconds.
Cases with s=5 require a good implementation of the meet-in-the-middle
search. They cannot be solved by exhaustive search within the five
hours of the competition. However, case 9 has the same solution
as case 3! This can be recognized by inspecting the input files.
The AES library allows for roughly 0.5e6 encryptions per second.
Decryption is about a factor two slower than encryption.
6/Some information about task DEPOT
The 25 test cases have the following characteristics.
Case N Shape P Note

1 3 3 1 1, 2, 3, 4
2 3 1 1 1 1 1, 2, 3, 4
3 3 2 1 2 1, 2, 3, 4
4 4 2 2 2 2, 3, 4
5 5 2 1 1 1 4 2, 3, 4
6 6 3 2 1 16 2, 3, 4 (largest output for N=6)
7 7 3 2 1 1 35 2, 3, 4 (largest output for N=7)
8 7 2 2 2 1 14 2, 3, 4
9 8 4 3 1 70 2?, 3, 4

10 8 4 2 1 1 90 2?, 3, 4 (largest output for N=8)
11 8 3 2 2 1 70 2?, 3, 4
12 9 3 2 2 2 84 3, 4
13 9 4 3 2 168 3, 4
14 9 4 2 2 1 216 3, 4 (largest output for N=9)
15 10 4 2 2 2 300 3, 4
16 10 4 3 2 1 768 3, 4 (largest output for N=10)
17 10 5 2 2 1 525 3, 4
18 11 6 5 132 3, 4
19 11 5 3 2 1 2310 3, 4 (largest output for N=11)
20 12 5 4 2 1 5775 3, 4
21 12 5 3 2 1 1 7700 3, 4 (largest output for N=12)
22 13 8 1 1 1 1 1 792 3, 4
23 13 2 2 2 2 2 2 1 429 3, 4
24 13 5 3 2 2 1 21450 3, 4 (largest output for N=13)
25 13 5 4 2 1 1 21450 3, 4 (largest output for N=13)
where
N = number of containers in depot (from input)
Shape = vector of subsequent row lengths (sum = N; input)
P = number of possible orders
Note = 1, solvable by pre-tabulating small cases
2, solvable by enumerating permutations, building depots, and
test
3, solvable by straightforward top-down backtracking
4, solvable by recursively breaking down the depot in reverse
order
In general, the number of possibilities goes up with N as N!/sqrt(N).
There also exist fast heuristic approaches that will find some but not
all
possibilities, and that may get a partial score.

×