Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
wjomlex commited on
Commit
c623d8c
1 Parent(s): 91a79e0

2013 Problems

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. 2013/finals/archiver.html +28 -0
  3. 2013/finals/archiver.in +3 -0
  4. 2013/finals/archiver.md +27 -0
  5. 2013/finals/archiver.out +63 -0
  6. 2013/finals/colored_trees.html +14 -0
  7. 2013/finals/colored_trees.in +61 -0
  8. 2013/finals/colored_trees.md +27 -0
  9. 2013/finals/colored_trees.out +60 -0
  10. 2013/finals/minesweeping.html +17 -0
  11. 2013/finals/minesweeping.in +196 -0
  12. 2013/finals/minesweeping.md +36 -0
  13. 2013/finals/minesweeping.out +20 -0
  14. 2013/finals/teleports.html +7 -0
  15. 2013/finals/teleports.in +32 -0
  16. 2013/finals/teleports.md +23 -0
  17. 2013/finals/teleports.out +31 -0
  18. 2013/quals/balanced_smileys.html +29 -0
  19. 2013/quals/balanced_smileys.in +63 -0
  20. 2013/quals/balanced_smileys.md +36 -0
  21. 2013/quals/balanced_smileys.out +62 -0
  22. 2013/quals/beautiful_strings.html +19 -0
  23. 2013/quals/beautiful_strings.in +51 -0
  24. 2013/quals/beautiful_strings.md +33 -0
  25. 2013/quals/beautiful_strings.out +50 -0
  26. 2013/quals/find_the_min.html +26 -0
  27. 2013/quals/find_the_min.in +73 -0
  28. 2013/quals/find_the_min.md +42 -0
  29. 2013/quals/find_the_min.out +36 -0
  30. 2013/round1/card_game.html +17 -0
  31. 2013/round1/card_game.in +0 -0
  32. 2013/round1/card_game.md +38 -0
  33. 2013/round1/card_game.out +50 -0
  34. 2013/round1/dead_pixels.html +35 -0
  35. 2013/round1/dead_pixels.in +41 -0
  36. 2013/round1/dead_pixels.md +46 -0
  37. 2013/round1/dead_pixels.out +40 -0
  38. 2013/round1/security.html +34 -0
  39. 2013/round1/security.in +322 -0
  40. 2013/round1/security.md +40 -0
  41. 2013/round1/security.out +107 -0
  42. 2013/round2/cake_cutting.html +29 -0
  43. 2013/round2/cake_cutting.in +51 -0
  44. 2013/round2/cake_cutting.md +30 -0
  45. 2013/round2/cake_cutting.out +50 -0
  46. 2013/round2/permutations.html +12 -0
  47. 2013/round2/permutations.in +0 -0
  48. 2013/round2/permutations.md +24 -0
  49. 2013/round2/permutations.out +60 -0
  50. 2013/round2/roboelection.html +29 -0
.gitattributes CHANGED
@@ -54,3 +54,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
  2012/finals/possible_medians.in filter=lfs diff=lfs merge=lfs -text
 
 
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
  2012/finals/possible_medians.in filter=lfs diff=lfs merge=lfs -text
57
+ 2013/finals/archiver.in filter=lfs diff=lfs merge=lfs -text
2013/finals/archiver.html ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>You are writing a new revolutionary archiver. The archive is essentially a
2
+ pair of non-decreasing sequences of integers of equal length <strong>K</strong>: <strong>0&le;x<sub>1</sub>&le;...&le;x<sub>k</sub></strong> and
3
+ <strong>0&le;y<sub>1</sub>&le;...&le;y<sub>k</sub></strong>.</p>
4
+
5
+ <p>
6
+ The decompression algorithm proceeds as follows:
7
+ <ol>
8
+ <li>Sequence <strong>(0,0), (x<sub>1</sub>,y<sub>1</sub>), ... (x<sub>k</sub>,y<sub>k</sub>), (x<sub>k</sub>, 0), (0, 0)</strong> defines a polygon <strong>P</strong></li>
9
+ <li>Starting from the point <strong>(0,0)</strong>, increase either <strong>x</strong> or <strong>y</strong> coordinate by 1 without
10
+ moving outside of <strong>P</strong>. If both moves are available, you should increase y.
11
+ After each step write <strong>0</strong> to output if incremented <strong>x</strong> or <strong>1</strong> otherwise.</li>
12
+ <li>Repeat step 2 until you end up in point <strong>(x<sub>k</sub>,y<sub>k</sub>)</strong>.</li>
13
+ </ol>
14
+ </p>
15
+
16
+ <p>Example: decompression of sequence <strong>(3,4), (7,6), (7,8)</strong> will produce string <strong>010101100100111</strong>.</p>
17
+
18
+ <p>Your task is to write a compression rate calculator, that is given
19
+ binary string s find the smallest value of <strong>K</strong> for which there exists archive
20
+ that decompresses to s.</p>
21
+
22
+ <h2>Input</h2>
23
+ <p>
24
+ The first line contains a single integer <strong>T</strong>, <strong>T</strong> &le; 20. <strong>T</strong> test cases follow, where each test case consists of one binary string with length <strong>&le; 1,000,000</strong>.
25
+ </p>
26
+
27
+ <h2>Output</h2>
28
+ <p>Output a single line containing the smallest possible <strong>K</strong>.</p>
2013/finals/archiver.in ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02c72140d253087b17bf251243f140530d0efa0cbeae2c2f1434dca789811a7a
3
+ size 53000149
2013/finals/archiver.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are writing a new revolutionary archiver. The archive is essentially a
2
+ pair of non-decreasing sequences of integers of equal length **K**:
3
+ **0≤x1≤...≤xk** and **0≤y1≤...≤yk**.
4
+
5
+ The decompression algorithm proceeds as follows:
6
+
7
+ 1. Sequence **(0,0), (x1,y1), ... (xk,yk), (xk, 0), (0, 0)** defines a polygon **P**
8
+ 2. Starting from the point **(0,0)**, increase either **x** or **y** coordinate by 1 without moving outside of **P**. If both moves are available, you should increase y. After each step write **0** to output if incremented **x** or **1** otherwise.
9
+ 3. Repeat step 2 until you end up in point **(xk,yk)**.
10
+
11
+ Example: decompression of sequence **(3,4), (7,6), (7,8)** will produce string
12
+ **010101100100111**.
13
+
14
+ Your task is to write a compression rate calculator, that is given binary
15
+ string s find the smallest value of **K** for which there exists archive that
16
+ decompresses to s.
17
+
18
+ ## Input
19
+
20
+ The first line contains a single integer **T**, **T** ≤ 20. **T** test cases
21
+ follow, where each test case consists of one binary string with length **≤
22
+ 1,000,000**.
23
+
24
+ ## Output
25
+
26
+ Output a single line containing the smallest possible **K**.
27
+
2013/finals/archiver.out ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 1
2
+ Case #2: 3
3
+ Case #3: 1
4
+ Case #4: 2
5
+ Case #5: 2
6
+ Case #6: 1
7
+ Case #7: 6
8
+ Case #8: 2
9
+ Case #9: 2
10
+ Case #10: 1
11
+ Case #11: 6318
12
+ Case #12: 6191
13
+ Case #13: 111
14
+ Case #14: 146
15
+ Case #15: 5903
16
+ Case #16: 10
17
+ Case #17: 11
18
+ Case #18: 868
19
+ Case #19: 178535
20
+ Case #20: 178229
21
+ Case #21: 100
22
+ Case #22: 38910
23
+ Case #23: 178183
24
+ Case #24: 805
25
+ Case #25: 39091
26
+ Case #26: 20
27
+ Case #27: 33
28
+ Case #28: 38890
29
+ Case #29: 177854
30
+ Case #30: 925
31
+ Case #31: 38913
32
+ Case #32: 39262
33
+ Case #33: 38829
34
+ Case #34: 958
35
+ Case #35: 15
36
+ Case #36: 124
37
+ Case #37: 927
38
+ Case #38: 124
39
+ Case #39: 178060
40
+ Case #40: 115
41
+ Case #41: 107
42
+ Case #42: 135
43
+ Case #43: 6258
44
+ Case #44: 39303
45
+ Case #45: 178549
46
+ Case #46: 177963
47
+ Case #47: 28
48
+ Case #48: 38961
49
+ Case #49: 110
50
+ Case #50: 114
51
+ Case #51: 178133
52
+ Case #52: 900
53
+ Case #53: 178475
54
+ Case #54: 922
55
+ Case #55: 6116
56
+ Case #56: 86
57
+ Case #57: 908
58
+ Case #58: 831
59
+ Case #59: 6253
60
+ Case #60: 38800
61
+ Case #61: 2
62
+ Case #62: 2
63
+ Case #63: 5
2013/finals/colored_trees.html ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>You are given two integers <strong>N</strong> and <strong>K</strong>, 1 &le; <strong>N</strong> &le; 1000, 1 &le; <strong>K</strong> &le; 10<sup>9</sup>.
2
+ Your task is to calculate how many distinct trees with <strong>N</strong> vertices there are with each vertex colored with one of <strong>K</strong> colors. Multiple vertices can have the same color, and not all colors need to be used. Two trees t1 and t2 are considered identical if there exists a
3
+ bijective function f from vertices of t1 to vertices of t2 such that each vertex
4
+ x in t1 is colored the same as f(x) in t2 and each pair of
5
+ vertices x, y in t1 is connected by an edge if and only if f(x) and f(y) are
6
+ connected by an edge in t2. A bijective function is a function that is both one-to-one and onto, meaning that f(x) = f(y) if and only if x = y, and for every vertex y in t2, there exists x in t1, such that f(x) = y.</p>
7
+
8
+ <h2>Input</h2>
9
+ <p>The first line contains a single integer <strong>T</strong>, <strong>T</strong> &le; 20. <strong>T</strong> test cases follow, where each test case consists of two integers: <strong>N</strong> and <strong>K</strong>.</p>
10
+ <h2>Output</h2>
11
+ <p>Output one single line with the number of colored trees.
12
+ Since this number might be very big, output it modulo <strong>1,000,000,007</strong>.</p>
13
+ <h2>Examples</h2>
14
+ <img src="https://fbcdn-dragon-a.akamaihd.net/cfs-ak-ash3/676523/506/293813004081038_-/tmp-/IV3SsS" />
2013/finals/colored_trees.in ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 60
2
+ 1 1
3
+ 2 10
4
+ 4 1
5
+ 3 2
6
+ 6 6
7
+ 10 1
8
+ 10 2
9
+ 10 3
10
+ 10 4
11
+ 10 5
12
+ 926 412855747
13
+ 988 302683841
14
+ 946 389327602
15
+ 942 755520817
16
+ 962 725592059
17
+ 962 124303339
18
+ 940 673811789
19
+ 925 136679808
20
+ 994 838951449
21
+ 902 822618701
22
+ 947 337000271
23
+ 998 956594967
24
+ 991 912015925
25
+ 968 65521556
26
+ 906 481262173
27
+ 937 871990538
28
+ 981 375923945
29
+ 938 683596292
30
+ 923 433322473
31
+ 944 458211048
32
+ 987 710152969
33
+ 995 704455203
34
+ 935 705926697
35
+ 910 923103943
36
+ 973 891354303
37
+ 942 655735865
38
+ 929 721706024
39
+ 988 761324387
40
+ 914 96614820
41
+ 909 926798536
42
+ 999 605008820
43
+ 980 702128526
44
+ 975 409870742
45
+ 976 12268300
46
+ 947 254554901
47
+ 929 259115399
48
+ 935 750540969
49
+ 990 308347332
50
+ 926 495858693
51
+ 939 352162907
52
+ 924 509555021
53
+ 908 980896097
54
+ 992 251628105
55
+ 920 213125789
56
+ 918 813842008
57
+ 973 815215859
58
+ 985 796383349
59
+ 999 337198141
60
+ 997 342625816
61
+ 984 619424491
2013/finals/colored_trees.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are given two integers **N** and **K**, 1 ≤ **N** ≤ 1000, 1 ≤ **K** ≤ 109.
2
+ Your task is to calculate how many distinct trees with **N** vertices there
3
+ are with each vertex colored with one of **K** colors. Multiple vertices can
4
+ have the same color, and not all colors need to be used. Two trees t1 and t2
5
+ are considered identical if there exists a bijective function f from vertices
6
+ of t1 to vertices of t2 such that each vertex x in t1 is colored the same as
7
+ f(x) in t2 and each pair of vertices x, y in t1 is connected by an edge if and
8
+ only if f(x) and f(y) are connected by an edge in t2. A bijective function is
9
+ a function that is both one-to-one and onto, meaning that f(x) = f(y) if and
10
+ only if x = y, and for every vertex y in t2, there exists x in t1, such that
11
+ f(x) = y.
12
+
13
+ ## Input
14
+
15
+ The first line contains a single integer **T**, **T** ≤ 20. **T** test cases
16
+ follow, where each test case consists of two integers: **N** and **K**.
17
+
18
+ ## Output
19
+
20
+ Output one single line with the number of colored trees. Since this number
21
+ might be very big, output it modulo **1,000,000,007**.
22
+
23
+ ## Examples
24
+
25
+ ![](https://fbcdn-dragon-a.akamaihd.net/cfs-ak-
26
+ ash3/676523/506/293813004081038_-/tmp-/IV3SsS)
27
+
2013/finals/colored_trees.out ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 1
2
+ Case #2: 55
3
+ Case #3: 2
4
+ Case #4: 6
5
+ Case #5: 96237
6
+ Case #6: 106
7
+ Case #7: 49377
8
+ Case #8: 2314119
9
+ Case #9: 37355726
10
+ Case #10: 329357000
11
+ Case #11: 676697473
12
+ Case #12: 45501090
13
+ Case #13: 779335707
14
+ Case #14: 26958241
15
+ Case #15: 657309864
16
+ Case #16: 451267804
17
+ Case #17: 622028903
18
+ Case #18: 334479648
19
+ Case #19: 642414015
20
+ Case #20: 816797514
21
+ Case #21: 280243367
22
+ Case #22: 554998124
23
+ Case #23: 622877339
24
+ Case #24: 360912148
25
+ Case #25: 706345038
26
+ Case #26: 807365774
27
+ Case #27: 22691064
28
+ Case #28: 200952258
29
+ Case #29: 14442301
30
+ Case #30: 627725927
31
+ Case #31: 466920491
32
+ Case #32: 449905771
33
+ Case #33: 674606235
34
+ Case #34: 611607618
35
+ Case #35: 667296665
36
+ Case #36: 46793700
37
+ Case #37: 567904841
38
+ Case #38: 689401724
39
+ Case #39: 143960408
40
+ Case #40: 520607720
41
+ Case #41: 619062585
42
+ Case #42: 453854295
43
+ Case #43: 378911046
44
+ Case #44: 416800629
45
+ Case #45: 407575022
46
+ Case #46: 725941690
47
+ Case #47: 688544022
48
+ Case #48: 234865105
49
+ Case #49: 164752491
50
+ Case #50: 878363551
51
+ Case #51: 710958705
52
+ Case #52: 252846121
53
+ Case #53: 992415400
54
+ Case #54: 299991045
55
+ Case #55: 894288598
56
+ Case #56: 963648258
57
+ Case #57: 839265476
58
+ Case #58: 853908598
59
+ Case #59: 622783661
60
+ Case #60: 555645540
2013/finals/minesweeping.html ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Do you know Minesweeper, the famous video game? The player is initially presented with a grid of undifferentiated squares. Some randomly selected squares, unknown to the player, are designated to contain mines. One square can contain at most one mine.<br>
2
+ <br>
3
+ The game is played by revealing squares of the grid, typically by clicking them. After that, a digit is revealed in the square, indicating the number of adjacent squares (under 8-way connectivity, that is, if two squares share either an edge or a corner, they are considered adjacent) that contain mines. If this number is zero then the surrounding squares are automatically also revealed. This process applies recursively and automatically every time a new square with count zero is revealed.<br>
4
+ <br>
5
+ Now, given a Minesweeper situation, you need to check if it is possible that such a situation can occur after <strong>exactly</strong> 1 click on the grid. Note that the game is designed in such a way, that the first clicked square never contains a mine.<br>
6
+ <br>
7
+ <h2>Input:</h2>
8
+ The first line contains a single integer <strong>T</strong>, <strong>T</strong> &le; 20. <br>
9
+ Then <strong>T</strong> test cases follow.<br>
10
+ The first line of each test case contains two integers <strong>n</strong>, <strong>m</strong> which indicate the size of the grid (<strong>1 &le; n &le; 16, 1 &le; m &le; 32</strong>).<br>
11
+ <strong>n</strong> lines follow, each line contains <strong>m</strong> characters describing the situation of the grid.<br>
12
+ The meaning of the characters are as follows:<br>
13
+ x: the square is not revealed after the first click<br>
14
+ 0 - 8: the number of mines that are adjacent to this square<br>
15
+ <br>
16
+ <h2>Output:</h2>
17
+ Output a single line containing 'Yes' if the situation is valid after 1 click, and 'No' otherwise (quotes for clarity).<br>
2013/finals/minesweeping.in ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 20
2
+ 8 8
3
+ xxxxxxxx
4
+ 1221124x
5
+ 0000001x
6
+ 1100011x
7
+ x10001xx
8
+ x10001xx
9
+ x11111xx
10
+ xxxxxxxx
11
+ 8 8
12
+ xxxxxxxx
13
+ 1221124x
14
+ 0000001x
15
+ 1100011x
16
+ x10001xx
17
+ x30001xx
18
+ x11111xx
19
+ xxxxxxxx
20
+ 5 5
21
+ xxxxx
22
+ xxxxx
23
+ xx1xx
24
+ xxxxx
25
+ xxxxx
26
+ 1 1
27
+ 0
28
+ 2 2
29
+ 5x
30
+ xx
31
+ 3 3
32
+ xxx
33
+ x2x
34
+ xxx
35
+ 5 3
36
+ 01x
37
+ 12x
38
+ xxx
39
+ x21
40
+ x10
41
+ 5 5
42
+ xxxxx
43
+ x535x
44
+ x303x
45
+ x535x
46
+ xxxxx
47
+ 5 5
48
+ xxxxx
49
+ xxxxx
50
+ xxxxx
51
+ xxxxx
52
+ xxxxx
53
+ 6 6
54
+ xxxxxx
55
+ x4224x
56
+ x2002x
57
+ x2002x
58
+ x4224x
59
+ xxxxxx
60
+ 6 6
61
+ xxxxxx
62
+ x4224x
63
+ x2002x
64
+ x2002x
65
+ x4214x
66
+ xxxxxx
67
+ 8 8
68
+ xxxxxxxx
69
+ xxx323xx
70
+ x21101xx
71
+ x20002xx
72
+ x11222xx
73
+ xxxxxxxx
74
+ xxxxxxxx
75
+ xxxxxxxx
76
+ 8 8
77
+ x100001x
78
+ 1100001x
79
+ 0000112x
80
+ 22101xxx
81
+ xx101xxx
82
+ xx211xxx
83
+ xxxxxxxx
84
+ xxxxxxxx
85
+ 9 9
86
+ xxxxxxxxx
87
+ xxxx3xxxx
88
+ xxx222xxx
89
+ xx21112xx
90
+ x3200023x
91
+ xx21112xx
92
+ xxx222xxx
93
+ xxxx3xxxx
94
+ xxxxxxxxx
95
+ 16 16
96
+ xxxxxxxxxxxxxxxx
97
+ xxxxxxxxxxxxxxxx
98
+ xxxxxxxxxxxxxxxx
99
+ xx211xxxxxxxxxxx
100
+ xx10111xxxxxxxxx
101
+ x210001xxxxxxxxx
102
+ 1100001xxxxxxxxx
103
+ 00000012xxxxxxxx
104
+ 00000001xxxxxxxx
105
+ 00000002xxxxxxxx
106
+ 01221001xxxxxxxx
107
+ 01xx21012xxxxxxx
108
+ 12xxx1002xxxxxxx
109
+ xx1111002xxxxxxx
110
+ 111000002xxxxxxx
111
+ 000000001xxxxxxx
112
+ 16 31
113
+ 0001x10000001xx1000000000000000
114
+ 0001x100000012x1000011100000000
115
+ 000111000000011100001x100000000
116
+ 0000000000000011100011100111000
117
+ 000000000000001x1000000001x1111
118
+ 00000000000000111000000001111xx
119
+ 000000000000000000000000000012x
120
+ 0000000000000000112110000000011
121
+ 01110000000000001xxx10001110000
122
+ 01x1000000000000112110001x10000
123
+ 0111000000000000000000001110000
124
+ 0000011100011100000000000000111
125
+ 000001x10002x3100000000111001xx
126
+ 000001110002xx1000000001x100111
127
+ 0000001221012210000000011100000
128
+ 0000001xx1000000000000000000000
129
+ 16 16
130
+ xxxxx201xxxxxxxx
131
+ xxxxx2012211xxxx
132
+ xxxxx1000002xxxx
133
+ xxxxx1000001xxxx
134
+ xxxxx1000001xxxx
135
+ xxxx11000001xxxx
136
+ xxxx10000001xxxx
137
+ xxxx10000001xxxx
138
+ xx2110013211xxxx
139
+ xx200001xxxxxxxx
140
+ xx422101xxxxxxxx
141
+ xxxxx111xxxxxxxx
142
+ xxxxxxxxxxxxxxxx
143
+ xxxxxxxxxxxxxxxx
144
+ xxxxxxxxxxxxxxxx
145
+ xxxxxxxxxxxxxxxx
146
+ 16 16
147
+ xxxxxxxxxxxxxxxx
148
+ 11112xxxxxxxxxxx
149
+ 00002xxxxxxxxxxx
150
+ 00014xxxxxxxxxxx
151
+ 0001xxxx21112xxx
152
+ 0001223x20002xxx
153
+ 1110002x20003xxx
154
+ xx21101110113xxx
155
+ xxxx1000001xxxxx
156
+ xxxx21000012xxxx
157
+ xxxxx1000001xxxx
158
+ xxxxx3110001xxxx
159
+ xxxxxxx21001xxxx
160
+ xxxxxxxx3234xxxx
161
+ xxxxxxxxxxxxxxxx
162
+ xxxxxxxxxxxxxxxx
163
+ 16 30
164
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
165
+ x212xx212xx212xx212xx212xx212x
166
+ x101xx101xx101xx101xx101xx101x
167
+ x101xx101xx101xx101xx101xx101x
168
+ x101xx101xx101xx101xx101xx101x
169
+ x101xx101xx101xx101xx101xx101x
170
+ x101xx101xx101xx101xx101xx101x
171
+ x101xx101xx101xx101xx101xx101x
172
+ x101xx101xx101xx101xx101xx101x
173
+ x101xx101xx101xx101xx101xx101x
174
+ x101xx101xx101xx101xx101xx101x
175
+ x101xx101xx101xx101xx101xx101x
176
+ x101xx101xx101xx101xx101xx101x
177
+ x101xx101xx101xx101xx101xx101x
178
+ x1012210122101221012210122101x
179
+ x1000000000000000000000000001x
180
+ 16 30
181
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
182
+ x212xx212xx212xx212xx111xx212x
183
+ x101xx101xx101xx101xx101xx101x
184
+ x101xx101xx101xx101xx101xx101x
185
+ x101xx101xx101xx101xx101xx101x
186
+ x101xx101xx101xx101xx101xx101x
187
+ x101xx101xx101xx101xx101xx101x
188
+ x101xx101xx101xx101xx101xx101x
189
+ x101xx101xx101xx101xx101xx101x
190
+ x101xx101xx101xx101xx101xx101x
191
+ x101xx101xx101xx101xx101xx101x
192
+ x101xx101xx101xx101xx101xx101x
193
+ x101xx101xx101xx101xx101xx101x
194
+ x101xx101xx101xx101xx101xx101x
195
+ x1012210122101221012210122101x
196
+ x1000000000000000000000000001x
2013/finals/minesweeping.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Do you know Minesweeper, the famous video game? The player is initially
2
+ presented with a grid of undifferentiated squares. Some randomly selected
3
+ squares, unknown to the player, are designated to contain mines. One square
4
+ can contain at most one mine.
5
+
6
+ The game is played by revealing squares of the grid, typically by clicking
7
+ them. After that, a digit is revealed in the square, indicating the number of
8
+ adjacent squares (under 8-way connectivity, that is, if two squares share
9
+ either an edge or a corner, they are considered adjacent) that contain mines.
10
+ If this number is zero then the surrounding squares are automatically also
11
+ revealed. This process applies recursively and automatically every time a new
12
+ square with count zero is revealed.
13
+
14
+ Now, given a Minesweeper situation, you need to check if it is possible that
15
+ such a situation can occur after **exactly** 1 click on the grid. Note that
16
+ the game is designed in such a way, that the first clicked square never
17
+ contains a mine.
18
+
19
+
20
+ ## Input:
21
+
22
+ The first line contains a single integer **T**, **T** ≤ 20.
23
+ Then **T** test cases follow.
24
+ The first line of each test case contains two integers **n**, **m** which
25
+ indicate the size of the grid (**1 ≤ n ≤ 16, 1 ≤ m ≤ 32**).
26
+ **n** lines follow, each line contains **m** characters describing the situation of the grid.
27
+ The meaning of the characters are as follows:
28
+ x: the square is not revealed after the first click
29
+ 0 - 8: the number of mines that are adjacent to this square
30
+
31
+
32
+ ## Output:
33
+
34
+ Output a single line containing 'Yes' if the situation is valid after 1 click,
35
+ and 'No' otherwise (quotes for clarity).
36
+
2013/finals/minesweeping.out ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: Yes
2
+ Case #2: No
3
+ Case #3: Yes
4
+ Case #4: Yes
5
+ Case #5: No
6
+ Case #6: Yes
7
+ Case #7: No
8
+ Case #8: Yes
9
+ Case #9: No
10
+ Case #10: Yes
11
+ Case #11: No
12
+ Case #12: Yes
13
+ Case #13: Yes
14
+ Case #14: No
15
+ Case #15: Yes
16
+ Case #16: Yes
17
+ Case #17: No
18
+ Case #18: Yes
19
+ Case #19: Yes
20
+ Case #20: No
2013/finals/teleports.html ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <p>Your house has <strong>2 &le; N &le; 500,000</strong> distinct rooms. None of the rooms have doors, but every room has a one way teleport which takes you to a different room. The same teleport will always go to the same room. You want to make sure that every room can be reached from every room, via a series of teleports. To do this, you are allowed to change the destination of some (or all) of the teleports.</p>
2
+ <p>What is the sum of the minimum number of teleports you have to change to achieve this, over all possible different starting configurations? Two starting configurations are different if for some room, the outgoing teleport goes to different rooms in the two configurations.</p>
3
+
4
+ <h2>Input</h2>
5
+ <p>The first line contains a single integer <strong>T</strong>, <strong>T</strong> &le; 20. <strong>T</strong> test cases follow, where each test case consists of one integer: <strong>N</strong></p>
6
+ <h2>Output</h2>
7
+ <p>Output one single line with the sum of the minimum number of teleports you have to change over all possible different starting configurations. Since this number might be very big, output it modulo <strong>1,000,000,007</strong></p>
2013/finals/teleports.in ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 31
2
+ 2
3
+ 3
4
+ 5
5
+ 10
6
+ 20
7
+ 58730
8
+ 415486
9
+ 362722
10
+ 348632
11
+ 382390
12
+ 81036
13
+ 439044
14
+ 490166
15
+ 470412
16
+ 347548
17
+ 387319
18
+ 81148
19
+ 52492
20
+ 364441
21
+ 500000
22
+ 357240
23
+ 78876
24
+ 443642
25
+ 459533
26
+ 453793
27
+ 451967
28
+ 437037
29
+ 425511
30
+ 301249
31
+ 435571
32
+ 450374
2013/finals/teleports.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Your house has **2 ≤ N ≤ 500,000** distinct rooms. None of the rooms have
2
+ doors, but every room has a one way teleport which takes you to a different
3
+ room. The same teleport will always go to the same room. You want to make sure
4
+ that every room can be reached from every room, via a series of teleports. To
5
+ do this, you are allowed to change the destination of some (or all) of the
6
+ teleports.
7
+
8
+ What is the sum of the minimum number of teleports you have to change to
9
+ achieve this, over all possible different starting configurations? Two
10
+ starting configurations are different if for some room, the outgoing teleport
11
+ goes to different rooms in the two configurations.
12
+
13
+ ## Input
14
+
15
+ The first line contains a single integer **T**, **T** ≤ 20. **T** test cases
16
+ follow, where each test case consists of one integer: **N**
17
+
18
+ ## Output
19
+
20
+ Output one single line with the sum of the minimum number of teleports you
21
+ have to change over all possible different starting configurations. Since this
22
+ number might be very big, output it modulo **1,000,000,007**
23
+
2013/finals/teleports.out ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 0
2
+ Case #2: 6
3
+ Case #3: 1720
4
+ Case #4: 435035973
5
+ Case #5: 93930085
6
+ Case #6: 445549105
7
+ Case #7: 868953501
8
+ Case #8: 896333447
9
+ Case #9: 87189708
10
+ Case #10: 638779500
11
+ Case #11: 547781467
12
+ Case #12: 625115175
13
+ Case #13: 660759949
14
+ Case #14: 408509902
15
+ Case #15: 136801877
16
+ Case #16: 87704054
17
+ Case #17: 531794345
18
+ Case #18: 840464439
19
+ Case #19: 111081362
20
+ Case #20: 559339757
21
+ Case #21: 613941079
22
+ Case #22: 125138122
23
+ Case #23: 606986861
24
+ Case #24: 344050087
25
+ Case #25: 959115003
26
+ Case #26: 362655882
27
+ Case #27: 266807035
28
+ Case #28: 436450540
29
+ Case #29: 991573175
30
+ Case #30: 9962767
31
+ Case #31: 314954537
2013/quals/balanced_smileys.html ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :(</p>
2
+
3
+ <p>Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.</p>
4
+
5
+ <p>A message has balanced parentheses if it consists of one of the following:</p>
6
+
7
+ <ul>
8
+ <li>- An empty string ""</li>
9
+ <li>- One or more of the following characters: 'a' to 'z', ' ' (a space) or ':' (a colon)</li>
10
+ <li>- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'. </li>
11
+ <li>- A message with balanced parentheses followed by another message with balanced parentheses.
12
+ <li>- A smiley face ":)" or a frowny face ":("</li>
13
+ </ul>
14
+
15
+ <p>Write a program that determines if there is a way to interpret his message while leaving the parentheses balanced. </p>
16
+
17
+ <h2>Input</h2>
18
+ <p>
19
+ The first line of the input contains a number <b>T </b>(1 &le; <b>T</b> &le; 50), the number of test cases. <br/>
20
+ The following <b>T</b> lines each contain a message of length <b>s</b> that you got from John.</p>
21
+
22
+ <h2>Output</h2>
23
+ <p>
24
+ For each of the test cases numbered in order from 1 to <b>T</b>, output "Case #i: " followed by a string stating whether or not it is possible that the message had balanced parentheses. If it is, the string should be "YES", else it should be "NO" (all quotes for clarity only)</p>
25
+ <h2>Constraints</h2>
26
+ <ul>
27
+ <li>1 &le; length of <b>s</b> &le; 100</li>
28
+ </ul>
29
+ <p>&nbsp;</p>
2013/quals/balanced_smileys.in ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 62
2
+ hacker cup: started :):)
3
+ :((
4
+ )(
5
+ i am sick today (:()
6
+ (:)
7
+ (:a))
8
+ :):)(::)a)()a((:a(a(((((a):)))(::()))(a)):))((a))):a:():)):()a(())aa(a(:))(aa()()::)):)(())
9
+ :)()((a)):(():a:a:)(:a)):)(()(:)::::(a(::a())(a):(:((((:(aa(()))a)(((((((((()a()a):)))((:)))))))))
10
+ a::):a()aa(:)a:))a:(aaa)aaa:(((aaa)(:)(a(:()(()()))aa)):(aa:a)))a(:)(()()(::())::()):((())
11
+ :()((())a():)aa)():()()(((a:::a(((()(a(:())(a))(()a((:(a:aa(a):(a((()(a))aa():a)((:(::a)):))))))))
12
+ a:(:(:::())(((:):::a)aa(((a((:a:):(:())(():()((a():(::))()()((:):)a(a):a))()aaa)(a()))):::
13
+ a((:()(a):aa()::())(:(::)()()(a::)(a))()))a:):)(:)a()(((a)):::((:(:(((:a((()(a)(()):aa)))())))
14
+ ((:):::(()()):)(()()():())aaa)(:(a:)a:((())a(((a(:())aa():a:)((()):)(()(:)(a())a:()a)a():(
15
+ (::a)a:)(a)a:(:a():))aa((a))()::::::aa()a((()(a((a(()(()a):a(((:))())(:((:))a):((:((:(()(:))))))))
16
+ (:)())a(:():)((a:a()()()(())((:a:(:():())):):(:((aa)()(:(:)a))a:(:):a)):()((())()a::::()(:)
17
+ ()a(:)(a:a):(())):a()():((a(:):a()()::)(a:)(()a((a:)(a)a(a:a:)(a)a(a:(()()()::a()a()(()a:())))
18
+ a(()(:)(((():(a):a))))a(()(aa()a:())a))a()aa:)a((():)()())a:aa())(:)()():)(:()()a():(((()a))
19
+ (()aa):a:():((a(():(a()(aa((a()(a)(:)()(a(::))):)(:a::a:()aaa::a):a(((()(:)))(((()a:)a::(())))))
20
+ a()a((a:))):::)((::(aaa:)a)a(((::(())a:()::a:aa))a(aaa)(a((()::(:():((:a(a))()(()(a()(():()))))
21
+ a(aa):a()()aa(a)a(((((a:)()()(::aa::(a)::(:():((aa)a:()::(((a)():)))((a(()((a)aa(a):((:::)))))
22
+ (()())a(a)((():)a:)(:)(:(a()a))):(:)(()a(()(:):)(aa)a())):(a:((a)))(a))(a)((:(()a():a(a(()))))
23
+ (((a)):()a(()(((:))a((:)():(((()()a)))(:a(::)(a)))(a)((a::():(a)():)a(a(a(:aa(:()(a(((((()))))))))
24
+ (a::()):)()aa:):::)a::)(((:)):(a():()a()))()aa):a:():(:()::)a:(a)a(()::(()((:())())()((a())(
25
+ ::):):)((():)(:(a((::)::(:(((((:(a):((a())(:):::((a(a(())(:)(()aa(:))(aa)a:)))))a(:))a)a(:)
26
+ (())((aa(a:(()())((:()):):)(():aa))a()(()))aaaa(:a):()(:aa):a)a():)a(((::(()::))))((a)():)
27
+ ():)((()():(:())))::aa((((:(((:)))::a:(:))()a)):(a):::((()a((a(aa(():))(():())((::a)a)):)()
28
+ a(a)::(((::)))())((a)(:((:a())):((::(:()(a)))i am trapped in a test case generator :(:(a(:::))
29
+ aa:a:((a)(aa(::((((::((())aaa(()a(()a)))::a(((:(():()aa))a((:a:(:()((:(:():)))()):a(()a(()))
30
+ (:((a)aa)::()(:))(()())a(a)(:::)))()a::)a:)a(:)(()a(a)(a()(::((:):(()()(:(:aa((a()((:(((:a))))))))
31
+ a()(())(())(:)(:((:aa)()(a(():()()a)a()():(((:))()(()(a:(:aa)())))(:::()((::aa)))))(:)(((()())
32
+ ()((:(:)()((:aa)()(():))((a)(:(a(()))((()()a):()())aa)((:())a()(:)a()))a)aaaa)((a(()(a)a(()))))
33
+ a(a)(a)::(a:()a()a)():)(:)aaa)(((a:(())()a):)(()))()(a)aa)a(:)()):a(:((a())a)()(a):a)a(():)
34
+ ()(((:(a(():a()((a)()a)a)a(:()))()(a(((:))())(a:)(aa(:a():()():(((a)a)(:a(a(:())a)():)()(())
35
+ aa:((:((a()(()()a(:)::)(:)a)(()a((a(aa((((((()aaa)):()aa):))))()()(((a))))()a)(()()))a())()
36
+ (::((:)()()aa())():)a:)()(():(a())aa)))()::((():))((a(:(()):a:)):))())):)a::)()(:a)()a(:)()
37
+ a(:(((()a)()()a(()()aa(a(a:::aaa(:):)a(a:a((a(())((()((:))))(a()(())():()()(a(()()a)((:)(a))))))))
38
+ ()(((a)((aa)))a)a()(a)(aa:a)()(((:())aa)):()():():a:(a)(a())a:)::a:(aa:):()((a:)())aa)a(a:)
39
+ :a:)(:))()(()()a)aaa::a()()a:()()a::)((()(a(a))))try implementing sleep sort if you are stuck:(:)a)
40
+ :)aa((:)aa)aa)(((:((a(a)):(())))a:(:(()):a)):))((a()))a()(:(()a()()a):)a((()())):aa:)a()aa
41
+ :((:()):))(a::(:)))(aa)a(a)()():)a(()(::()))((((()a)a((((()())((a()()()(()()(():a))()a)):a))))))
42
+ (a(aa()a)()aa(a:((a(()()(((()aa::)(::(aa:)(a()(:))(aa)a):a)()::):(a))))):((a(:(a():):()::(
43
+ aa(()())((a))(:((()a:()())(a):)())a():(:)))(:):a):)()(((a((()a(a()((aa(:)))a)((aa((a))(a)))))))
44
+ ():aa(()())::)():()((()()((:((:::))()aa)(())(:))(()(a:()a()()())(a)()))((((::):(())()))((:))
45
+ :(a):(:)aa)a(:()::():))a:aaa:)(:)((()()))a()(((()(:)))(:(aa:()())())a((a)a:(:()))(a((():)))
46
+ ()((:a(a()()a))())((:a(:a)(()a((((a((a(()(:aa()()()))):)(():):)(:(a))():(())(():()):):(()a))
47
+ a:)a():a:((:aaa))()((a((aa(((())(a))a(:(a)a()(aa(()))(aa:)(()a)a()a((()a()))((a)(::(:((((()))))))))
48
+ (()(:a():)))()aa(:)((:(a(::a))())()(())))aa:)()()::a(((((a()):()(:()(((:)()a()(((a()(a:()))))))))
49
+ :::)(()::))a:):::()(a(:)(a)a)())::)()(()a)a(a)may the best hacker win:aa:)a()(())aa:::)(:())aa
50
+ (()a:::)a((:))(::a((a)(::aa((a):(:)(:)a()a(()))))facebook is hiring:)()()()a(a((:(a((:)()()))a))
51
+ ()aa():):(a:))a()a(:))()()((()(:((())a)()(:)()):)::(()a:(:(:)((:(:a):(()(((a(())a:aaaa(()))))
52
+ (::a((a)a:()):):a)aa:)a(:::))(a())aa(a():))(:)a)((():)(:a:)a))):a(a)((:()(()())a))()a((()a))
53
+ :a()(())(:a(:(aa)a)):aaa()a(((a(:()))a))a():()a:)(a)aa(a)((():):aa((a)a((()):)((a)(((aa:(()))))
54
+ :a(((:(:)))((a()()(()aa)(a)(:()::((a)())(()(a(:())()():(()a)()):))a))()()aaa)()a((:)((((())))
55
+ (a())(::)(a))():(((a(()(:))a(:)))(:(:(:((():)(a))(:))(a)():(:(()aa):)(a((())a)a((a):)()(:(
56
+ :)(a):)(a)(a()(()(()):a()(a))(a(a))a(a:)))a((:aa::()()()aa)):):((():)):(::a:a)()a()):):)()
57
+ (()()((((((((:)aa())a():(:()a(a)):)()(:))())(a)a((((a:()(a((()()a)a)):(a(a)))a)((():))):a())
58
+ ::)(a()(::)):):)((()((:)::a:(((:a))(a(:():))a))i love jello:aaaa:(:a:)(:a:(()::(::aa)a)):(:())
59
+ a((aa)(:a()a())()(()((()((a:(a)()aaa()(:::(a()):((:())(()))(((aa:(:a)):):(():)))((a()(()(())))
60
+ ():)a((a:((aaa(()))(((()a))()))a(:)):)a((:())(a:(:):((a(:(::())a()())::()a)(a)):((aa)a(:(())
61
+ (:)())()a()(()::(():())(:))):((:(a:())()()a)((()(a))()(:a()a:((:)a(())(:)(()())))())(a)))()
62
+ ::((:))(((:)(aaa)(a())()(a:)(:)(:)()):)a())aa)())(():a):()::):)a()())a()):):(:a)a):()(a)(a)
63
+ (:a()a)(a)a(aa(()(::)())(:a(a):()a(a()a(()():)))this is a min cost max flow problem(a)((a(()a)))a
2013/quals/balanced_smileys.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Your friend John uses a lot of emoticons when you talk to him on Messenger. In
2
+ addition to being a person who likes to express himself through emoticons, he
3
+ hates unbalanced parenthesis so much that it makes him go :(
4
+
5
+ Sometimes he puts emoticons within parentheses, and you find it hard to tell
6
+ if a parenthesis really is a parenthesis or part of an emoticon.
7
+
8
+ A message has balanced parentheses if it consists of one of the following:
9
+
10
+ * \- An empty string ""
11
+ * \- One or more of the following characters: 'a' to 'z', ' ' (a space) or ':' (a colon)
12
+ * \- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'.
13
+ * \- A message with balanced parentheses followed by another message with balanced parentheses.
14
+ * \- A smiley face ":)" or a frowny face ":("
15
+
16
+ Write a program that determines if there is a way to interpret his message
17
+ while leaving the parentheses balanced.
18
+
19
+ ## Input
20
+
21
+ The first line of the input contains a number **T **(1 ≤ **T** ≤ 50), the
22
+ number of test cases.
23
+ The following **T** lines each contain a message of length **s** that you got
24
+ from John.
25
+
26
+ ## Output
27
+
28
+ For each of the test cases numbered in order from 1 to **T**, output "Case #i:
29
+ " followed by a string stating whether or not it is possible that the message
30
+ had balanced parentheses. If it is, the string should be "YES", else it should
31
+ be "NO" (all quotes for clarity only)
32
+
33
+ ## Constraints
34
+
35
+ * 1 ≤ length of **s** ≤ 100
36
+
2013/quals/balanced_smileys.out ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: YES
2
+ Case #2: NO
3
+ Case #3: NO
4
+ Case #4: YES
5
+ Case #5: YES
6
+ Case #6: NO
7
+ Case #7: YES
8
+ Case #8: YES
9
+ Case #9: YES
10
+ Case #10: YES
11
+ Case #11: YES
12
+ Case #12: YES
13
+ Case #13: YES
14
+ Case #14: YES
15
+ Case #15: YES
16
+ Case #16: YES
17
+ Case #17: YES
18
+ Case #18: YES
19
+ Case #19: YES
20
+ Case #20: YES
21
+ Case #21: YES
22
+ Case #22: NO
23
+ Case #23: NO
24
+ Case #24: NO
25
+ Case #25: YES
26
+ Case #26: YES
27
+ Case #27: YES
28
+ Case #28: NO
29
+ Case #29: NO
30
+ Case #30: NO
31
+ Case #31: YES
32
+ Case #32: YES
33
+ Case #33: NO
34
+ Case #34: YES
35
+ Case #35: YES
36
+ Case #36: NO
37
+ Case #37: YES
38
+ Case #38: YES
39
+ Case #39: YES
40
+ Case #40: YES
41
+ Case #41: YES
42
+ Case #42: NO
43
+ Case #43: YES
44
+ Case #44: YES
45
+ Case #45: YES
46
+ Case #46: NO
47
+ Case #47: YES
48
+ Case #48: YES
49
+ Case #49: YES
50
+ Case #50: NO
51
+ Case #51: YES
52
+ Case #52: NO
53
+ Case #53: NO
54
+ Case #54: NO
55
+ Case #55: YES
56
+ Case #56: YES
57
+ Case #57: YES
58
+ Case #58: NO
59
+ Case #59: YES
60
+ Case #60: YES
61
+ Case #61: YES
62
+ Case #62: YES
2013/quals/beautiful_strings.html ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.</p>
2
+
3
+ <p>Given a string <b>s</b>, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.</p>
4
+
5
+ <p>The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)</p>
6
+
7
+ <p>You're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?</p>
8
+
9
+ <p><h2>Input</h2>
10
+ The input file consists of a single integer <strong>m</strong> followed by <strong>m</strong> lines.</p>
11
+
12
+ <p><h2>Output</h2>
13
+ Your output should consist of, for each test case, a line containing the string "Case #<strong>x</strong>: <strong>y</strong>" where <strong>x</strong> is the case number (with 1 being the first case in the input file, 2 being the second, etc.) and <strong>y</strong> is the maximum beauty for that test case.
14
+ </p>
15
+
16
+ <p><h2>Constraints</h2>
17
+ 5 &le; <strong>m</strong> &le; 50</strong><br/>
18
+ 2 &le; length of <strong>s</strong> &le; 500<br/>
19
+ </p>
2013/quals/beautiful_strings.in ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 50
2
+ ABbCcc
3
+ Good luck in the Facebook Hacker Cup this year!
4
+ Ignore punctuation, please :)
5
+ Sometimes test cases are hard to make up.
6
+ So I just go consult Professor Dalves
7
+ Zg.W!eoV.kM.TFabbmZhjFqRksbAuih)kBYgihWZxcVAaFoKC.NTB Y SrtDf:srGWBLxqjEmu)UcylZgKmIYEdYW;m;svznK!i).sTSERQRH:DD)F
8
+ yi b XO.ngKwnWVGJpbfOeRY(WXlenrtTYEhyNASZofRoRjzKY:g.z(AvHnbGaeZpvKkgBf(Rx)cM!YsNQTTI OH)dpl!XCmsCzqwtgz
9
+ Ydym(U.XvPVvUgXwWG)Z)jsy.PfVmMnenCqZeHpwCpfngzBJ) yOmGY:NCiwllBApKr FJGRPEdRDTGzx!mBo!Ef.aOXSfrk.kdV zU(.amVgwb;e:aFjmOj::EAxHlVTorHvx)gxEcS;I!bOntIARzkcNoa;sRQ::Ff:xbUT;wsXNTUzWuL;YLpRFT(YsGlHSWRO mN!bTrgm:DW(fAEDfNfP:bMGU(Nuv!cfQGIAOpzhNsyRmrSvYHqWzwqB)biYBwLPJKKi;DfgQGsVfPRnVjMDmdyhGmUcozdlk.H!uxv.Ku(psxeDKcaRuVKMHAlrEOsFlTbnl! txNh EgQGuDxmfHMgWSPxrruYCq)ttl(hgWGwhMtMOBevRGP!fNiVIJa.ifyMlWhccykE)wrWcvykmMG(F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iL(TpysvsxBoYjWfTKZnqxghhrfOn zcccylJHcYfaomUAiRyDs(zMNXjLwTesuknALUSlVluBkTKdNpuXTf!skUALIGoL;Rh!EETTtbfhNtyglGpFNg!;ocwj:g!HxtwGYtVV
2013/quals/beautiful_strings.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ When John was a little kid he didn't have much to do. There was no internet,
2
+ no Facebook, and no programs to hack on. So he did the only thing he could...
3
+ he evaluated the beauty of strings in a quest to discover the most beautiful
4
+ string in the world.
5
+
6
+ Given a string **s**, little Johnny defined the beauty of the string as the
7
+ sum of the beauty of the letters in it.
8
+
9
+ The beauty of each letter is an integer between 1 and 26, inclusive, and no
10
+ two letters have the same beauty. Johnny doesn't care about whether letters
11
+ are uppercase or lowercase, so that doesn't affect the beauty of a letter.
12
+ (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)
13
+
14
+ You're a student writing a report on the youth of this famous hacker. You
15
+ found the string that Johnny considered most beautiful. What is the maximum
16
+ possible beauty of this string?
17
+
18
+ ## Input
19
+
20
+ The input file consists of a single integer **m** followed by **m** lines.
21
+
22
+ ## Output
23
+
24
+ Your output should consist of, for each test case, a line containing the
25
+ string "Case #**x**: **y**" where **x** is the case number (with 1 being the
26
+ first case in the input file, 2 being the second, etc.) and **y** is the
27
+ maximum beauty for that test case.
28
+
29
+ ## Constraints
30
+
31
+ 5 ≤ **m** ≤ 50**
32
+ 2 ≤ length of **s** ≤ 500
33
+
2013/quals/beautiful_strings.out ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 152
2
+ Case #2: 754
3
+ Case #3: 491
4
+ Case #4: 729
5
+ Case #5: 646
6
+ Case #6: 1581
7
+ Case #7: 1526
8
+ Case #8: 5991
9
+ Case #9: 5113
10
+ Case #10: 6469
11
+ Case #11: 3558
12
+ Case #12: 3555
13
+ Case #13: 6004
14
+ Case #14: 1336
15
+ Case #15: 3897
16
+ Case #16: 1657
17
+ Case #17: 2475
18
+ Case #18: 1653
19
+ Case #19: 4566
20
+ Case #20: 2802
21
+ Case #21: 4877
22
+ Case #22: 2589
23
+ Case #23: 5433
24
+ Case #24: 5982
25
+ Case #25: 3958
26
+ Case #26: 5749
27
+ Case #27: 1784
28
+ Case #28: 348
29
+ Case #29: 2108
30
+ Case #30: 3593
31
+ Case #31: 4266
32
+ Case #32: 2138
33
+ Case #33: 3974
34
+ Case #34: 1169
35
+ Case #35: 1358
36
+ Case #36: 2962
37
+ Case #37: 3695
38
+ Case #38: 5510
39
+ Case #39: 6059
40
+ Case #40: 2081
41
+ Case #41: 3056
42
+ Case #42: 3191
43
+ Case #43: 5495
44
+ Case #44: 2348
45
+ Case #45: 1811
46
+ Case #46: 6097
47
+ Case #47: 3559
48
+ Case #48: 3953
49
+ Case #49: 2254
50
+ Case #50: 5873
2013/quals/find_the_min.html ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p> After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, <b>m</b>, which contains <b>n</b> non-negative integers. However, only the first <b>k</b> values of the array are known to him, and he wants to figure out the rest. </p>
2
+
3
+ <p> John knows the following: for each index <b>i</b>, where <b>k</b> &le; <b>i</b> &lt; <b>n, m</b>[<b>i</b>] is the minimum non-negative integer which is *not* contained in the previous *<b>k</b>* values of <b>m</b>. </p>
4
+
5
+ <p> For example, if <b>k</b> = 3, <b>n</b> = 4 and the known values of <b>m</b> are [2, 3, 0], he can figure out that <b>m</b>[3] = 1. </p>
6
+
7
+ <p> John is very busy making the world more open and connected, as such, he doesn't have time to figure out the rest of the array. It is your task to help him. </p>
8
+
9
+ <p> Given the first <b>k</b> values of <b>m</b>, calculate the <b>n</b><sup>th</sup> value of this array. (i.e. <b>m</b>[<b>n</b> - 1]). </p>
10
+
11
+ <p> Because the values of <b>n</b> and <b>k</b> can be very large, we use a pseudo-random number generator to calculate the first <b>k</b> values of <b>m</b>.
12
+ Given non-negative integers <b>a</b>, <b>b</b>, <b>c</b> and positive integer <b>r</b>, the known values of <b>m</b> can be calculated as follows: </p>
13
+
14
+ <ul>
15
+ <li><b>m</b>[0] = <b>a</b></li>
16
+ <li><b>m</b>[<b>i</b>] = (<b>b</b> * <b>m</b>[<b>i</b> - 1] + <b>c</b>) % <b>r</b>, 0 &lt; <b>i</b> &lt; <b>k</b></li>
17
+ </ul>
18
+
19
+ <p><h3>Input</h3>
20
+ The first line contains an integer <b>T</b> (<b>T</b> &le; 20), the number of test cases.<br/>
21
+ This is followed by <b>T</b> test cases, consisting of 2 lines each.<br/>
22
+ The first line of each test case contains 2 space separated integers, <b>n</b>, <b>k</b> (1 &le; <b>k</b> &le; 10<sup>5</sup>, <b>k</b> &lt; <b>n</b> &le;10<sup>9</sup>).<br/>
23
+ The second line of each test case contains 4 space separated integers <b>a</b>, <b>b</b>, <b>c</b>, <b>r</b> (0 &le; <b>a</b>, <b>b</b>, <b>c</b> &le; 10<sup>9</sup>, 1 &le; <b>r</b> &le; 10<sup>9</sup>). </p>
24
+
25
+ <p><h3>Output</h3>
26
+ For each test case, output a single line containing the case number and the <b>n</b><sup>th</sup> element of <b>m</b>. </p>
2013/quals/find_the_min.in ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 36
2
+ 97 39
3
+ 34 37 656 97
4
+ 186 75
5
+ 68 16 539 186
6
+ 137 49
7
+ 48 17 461 137
8
+ 98 59
9
+ 6 30 524 98
10
+ 46 18
11
+ 7 11 9 46
12
+ 66 39
13
+ 35 2 589 66
14
+ 59 26
15
+ 14 19 681 59
16
+ 82 81
17
+ 58 56 739 82
18
+ 164 96
19
+ 76 2 193 164
20
+ 22 21
21
+ 1 4 869 22
22
+ 78 51
23
+ 3 5 5 51230
24
+ 198 81
25
+ 8 5 7 83495
26
+ 220 88
27
+ 1 8 3 58265
28
+ 254 99
29
+ 1 8 9 74990
30
+ 28 21
31
+ 6 5 1 85919
32
+ 110 53
33
+ 7 7 1 64417
34
+ 177 73
35
+ 7 7 5 56401
36
+ 73 26
37
+ 5 8 4 54214
38
+ 131 74
39
+ 1 9 10 78736
40
+ 112 73
41
+ 1 5 3 64100
42
+ 497151700 96511
43
+ 9 7 6 999919625
44
+ 977365070 59489
45
+ 8 5 9 999966210
46
+ 249718282 93729
47
+ 1 5 6 999917908
48
+ 714311129 39521
49
+ 9 5 9 999998192
50
+ 232959116 56689
51
+ 4 9 1 999903057
52
+ 840698758 13331
53
+ 8 7 10 999955808
54
+ 218492221 46085
55
+ 3 7 1 999969453
56
+ 45068754 29153
57
+ 2 9 5 999904402
58
+ 693840425 90561
59
+ 2 6 7 999957328
60
+ 640834505 28785
61
+ 3 9 1 999946125
62
+ 1000000000 100000
63
+ 1 1 0 2
64
+ 1000000000 100000
65
+ 100000 1 0 1000000000
66
+ 1000000000 100000
67
+ 1 1 1 1000000000
68
+ 1000000000 100000
69
+ 999999999 1 999999999 1000000000
70
+ 1000000000 100000
71
+ 99999 1 99999 100000
72
+ 1000000000 1
73
+ 12 7 74 12
2013/quals/find_the_min.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ After sending smileys, John decided to play with arrays. Did you know that
2
+ hackers enjoy playing with arrays? John has a zero-based index array, **m**,
3
+ which contains **n** non-negative integers. However, only the first **k**
4
+ values of the array are known to him, and he wants to figure out the rest.
5
+
6
+ John knows the following: for each index **i**, where **k** ≤ **i** < **n,
7
+ m**[**i**] is the minimum non-negative integer which is *not* contained in the
8
+ previous ***k*** values of **m**.
9
+
10
+ For example, if **k** = 3, **n** = 4 and the known values of **m** are [2, 3,
11
+ 0], he can figure out that **m**[3] = 1.
12
+
13
+ John is very busy making the world more open and connected, as such, he
14
+ doesn't have time to figure out the rest of the array. It is your task to help
15
+ him.
16
+
17
+ Given the first **k** values of **m**, calculate the **n**th value of this
18
+ array. (i.e. **m**[**n** \- 1]).
19
+
20
+ Because the values of **n** and **k** can be very large, we use a pseudo-
21
+ random number generator to calculate the first **k** values of **m**. Given
22
+ non-negative integers **a**, **b**, **c** and positive integer **r**, the
23
+ known values of **m** can be calculated as follows:
24
+
25
+ * **m**[0] = **a**
26
+ * **m**[**i**] = (**b** * **m**[**i** \- 1] + **c**) % **r**, 0 < **i** < **k**
27
+
28
+ ### Input
29
+
30
+ The first line contains an integer **T** (**T** ≤ 20), the number of test
31
+ cases.
32
+ This is followed by **T** test cases, consisting of 2 lines each.
33
+ The first line of each test case contains 2 space separated integers, **n**,
34
+ **k** (1 ≤ **k** ≤ 105, **k** < **n** ≤109).
35
+ The second line of each test case contains 4 space separated integers **a**,
36
+ **b**, **c**, **r** (0 ≤ **a**, **b**, **c** ≤ 109, 1 ≤ **r** ≤ 109).
37
+
38
+ ### Output
39
+
40
+ For each test case, output a single line containing the case number and the
41
+ **n**th element of **m**.
42
+
2013/quals/find_the_min.out ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 8
2
+ Case #2: 38
3
+ Case #3: 41
4
+ Case #4: 40
5
+ Case #5: 12
6
+ Case #6: 30
7
+ Case #7: 12
8
+ Case #8: 0
9
+ Case #9: 76
10
+ Case #10: 0
11
+ Case #11: 26
12
+ Case #12: 34
13
+ Case #13: 42
14
+ Case #14: 54
15
+ Case #15: 6
16
+ Case #16: 2
17
+ Case #17: 29
18
+ Case #18: 19
19
+ Case #19: 58
20
+ Case #20: 38
21
+ Case #21: 18389
22
+ Case #22: 3860
23
+ Case #23: 21563
24
+ Case #24: 30023
25
+ Case #25: 19906
26
+ Case #26: 9502
27
+ Case #27: 44581
28
+ Case #28: 25824
29
+ Case #29: 44944
30
+ Case #30: 573
31
+ Case #31: 90002
32
+ Case #32: 90001
33
+ Case #33: 90001
34
+ Case #34: 90001
35
+ Case #35: 9999
36
+ Case #36: 0
2013/round1/card_game.html ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>John is playing a game with his friends. The game's rules are as follows: There is deck of <strong>N</strong> cards from which each person is dealt a hand of <strong>K</strong> cards. Each card has an integer value representing its strength. A hand's strength is determined by the value of the highest card in the hand. The person with the strongest hand wins the round. Bets are placed before each player reveals the strength of their hand.</p>
2
+
3
+ <p>John needs your help to decide when to bet. He decides he wants to bet when the strength of his hand is higher than the average hand strength. Hence John wants to calculate the average strength of ALL possible sets of hands. John is very good at division, but he needs your help in calculating the sum of the strengths of all possible hands.</p>
4
+
5
+ <h2>Problem</h2>
6
+ <p>You are given an array <strong>a</strong> with <strong>N &le; 10,000</strong> different integer numbers and a number, <strong>K</strong>, where <strong>1 &le; K &le; N</strong>. For all possible subsets of <strong>a</strong> of size <strong>K</strong> find the sum of their maximal elements modulo <strong>1,000,000,007</strong>.</p>
7
+
8
+ <h2>Input</h2>
9
+ <p>The first line contains the number of test cases <strong>T</strong>, where <strong> 1 &le; T &le; 25 </strong></p>
10
+
11
+ <p>Each case begins with a line containing integers <strong>N</strong> and <strong>K</strong>. The next line contains <strong>N</strong> space-separated numbers <strong>0 &le; a [i] &le; 2,000,000,000</strong>, which describe the array <strong>a</strong>.</p>
12
+
13
+ <h2>Output</h2>
14
+ <p>For test case <strong>i</strong>, numbered from <strong>1</strong> to <strong>T</strong>, output "Case #i: ", followed by a single integer, the sum of maximal elements for all subsets of size <strong>K</strong> modulo 1,000,000,007.</p>
15
+
16
+ <h2>Example</h2>
17
+ For <strong>a = [3, 6, 2, 8]</strong> and <strong>N = 4</strong> and <strong>K = 3</strong>, the maximal numbers among all triples are <strong>6, 8, 8, 8</strong> and the sum is <strong>30</strong>.
2013/round1/card_game.in ADDED
The diff for this file is too large to render. See raw diff
 
2013/round1/card_game.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ John is playing a game with his friends. The game's rules are as follows:
2
+ There is deck of **N** cards from which each person is dealt a hand of **K**
3
+ cards. Each card has an integer value representing its strength. A hand's
4
+ strength is determined by the value of the highest card in the hand. The
5
+ person with the strongest hand wins the round. Bets are placed before each
6
+ player reveals the strength of their hand.
7
+
8
+ John needs your help to decide when to bet. He decides he wants to bet when
9
+ the strength of his hand is higher than the average hand strength. Hence John
10
+ wants to calculate the average strength of ALL possible sets of hands. John is
11
+ very good at division, but he needs your help in calculating the sum of the
12
+ strengths of all possible hands.
13
+
14
+ ## Problem
15
+
16
+ You are given an array **a** with **N ≤ 10,000** different integer numbers and
17
+ a number, **K**, where **1 ≤ K ≤ N**. For all possible subsets of **a** of
18
+ size **K** find the sum of their maximal elements modulo **1,000,000,007**.
19
+
20
+ ## Input
21
+
22
+ The first line contains the number of test cases **T**, where ** 1 ≤ T ≤ 25 **
23
+
24
+ Each case begins with a line containing integers **N** and **K**. The next
25
+ line contains **N** space-separated numbers **0 ≤ a [i] ≤ 2,000,000,000**,
26
+ which describe the array **a**.
27
+
28
+ ## Output
29
+
30
+ For test case **i**, numbered from **1** to **T**, output "Case #i: ",
31
+ followed by a single integer, the sum of maximal elements for all subsets of
32
+ size **K** modulo 1,000,000,007.
33
+
34
+ ## Example
35
+
36
+ For **a = [3, 6, 2, 8]** and **N = 4** and **K = 3**, the maximal numbers
37
+ among all triples are **6, 8, 8, 8** and the sum is **30**.
38
+
2013/round1/card_game.out ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 30
2
+ Case #2: 400
3
+ Case #3: 103
4
+ Case #4: 1122
5
+ Case #5: 2621483
6
+ Case #6: 408515
7
+ Case #7: 1004580
8
+ Case #8: 40755786
9
+ Case #9: 999929
10
+ Case #10: 530567225
11
+ Case #11: 322338625
12
+ Case #12: 221309511
13
+ Case #13: 600929371
14
+ Case #14: 754869952
15
+ Case #15: 50004993
16
+ Case #16: 670107979
17
+ Case #17: 283588254
18
+ Case #18: 493922435
19
+ Case #19: 607347357
20
+ Case #20: 712376460
21
+ Case #21: 313254333
22
+ Case #22: 335296073
23
+ Case #23: 915868532
24
+ Case #24: 460246520
25
+ Case #25: 514894931
26
+ Case #26: 526863429
27
+ Case #27: 464198425
28
+ Case #28: 260278457
29
+ Case #29: 794655996
30
+ Case #30: 855587163
31
+ Case #31: 584262053
32
+ Case #32: 633477677
33
+ Case #33: 681471440
34
+ Case #34: 120711485
35
+ Case #35: 90889566
36
+ Case #36: 947249559
37
+ Case #37: 190955579
38
+ Case #38: 610605848
39
+ Case #39: 832615581
40
+ Case #40: 130056877
41
+ Case #41: 707469732
42
+ Case #42: 705325059
43
+ Case #43: 490200453
44
+ Case #44: 724934349
45
+ Case #45: 624738998
46
+ Case #46: 850880749
47
+ Case #47: 150608471
48
+ Case #48: 180665000
49
+ Case #49: 216384039
50
+ Case #50: 159672993
2013/round1/dead_pixels.html ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>John's friend Peter purchases a new high resolution monitor with dimension <b>W</b> * <b>H</b> where <b>W</b> is the number of pixels in each row (i.e. width) and <b>H</b> is the number of pixels in each column (i.e. height).</p>
2
+
3
+ <p>However, there are <b>N</b> dead pixels on the monitor. The <b>i</b>-th dead pixel is located at (<b>x</b>[<b>i</b>], <b>y</b>[<b>i</b>]). (0, 0) is the top-left pixel and (<b>W</b> - 1, <b>H</b> - 1) is the bottom-right pixel. The locations of the dead pixels could be generated by 6 given integers <b>X</b>, <b>Y</b>, <b>a</b>, <b>b</b>, <b>c</b> and <b>d</b> by the following rules. If 2 pixels are at the same location, they are considered the same. It is possible that there are less than <b>N</b> <strong>distinct</strong> dead pixels.</p>
4
+
5
+ <p>
6
+ <li><b>x</b>[0] = <b>X</b></li>
7
+ <li><b>y</b>[0] = <b>Y</b></li>
8
+ <li><b>x</b>[<b>i</b>] = (<b>x</b>[<b>i</b> - 1] * <b>a</b> + <b>y</b>[<b>i</b> - 1] * <b>b</b> + 1) % <b>W</b> (for 0 &lt; <b>i</b> &lt; <b>N</b>)</li>
9
+ <li><b>y</b>[<b>i</b>] = (<b>x</b>[<b>i</b> - 1] * <b>c</b> + <b>y</b>[<b>i</b> - 1] * <b>d</b> + 1) % <b>H</b> (for 0 &lt; <b>i</b> &lt; <b>N</b>)</li>
10
+ </p>
11
+
12
+ <p>Peter connects his monitor to his computer and opens an image with dimension <b>P</b> (width) * <b>Q</b> (height). How many unique positions can the image be placed so that it can be displayed perfectly (i.e. all pixels of the picture are shown on the monitor)? The image cannot be rotated.</p>
13
+
14
+ <h3>Input</h3>
15
+ <p>
16
+ The first line contains an integer <b>T</b>, which is the number of test cases.
17
+ Then <b>T</b> test cases follow.
18
+ Each test case contains 11 integers <b>W</b>, <b>H</b>, <b>P</b>, <b>Q</b>, <b>N</b>, <b>X</b>, <b>Y</b>, <b>a</b>, <b>b</b>, <b>c</b>, <b>d</b>.
19
+ </p>
20
+
21
+ <h3>Output</h3><p>
22
+ For each of the test cases numbered in order from 1 to <b>T</b>,
23
+ output "Case #", followed by the case number (with 1 being the first test case), followed by ": ", followed by an integer which is the number of different possible positions for the poster.
24
+ </p>
25
+
26
+ <h3>Constraints</h3>
27
+ <li>1 &le; <b>T</b> &le; 20</li>
28
+ <li>1 &le; <b>W</b>, <b>H</b> &le; 40 000</li>
29
+ <li>1 &le; <b>P</b> &le; <b>W</b></li>
30
+ <li>1 &le; <b>Q</b> &le; <b>H</b></li>
31
+ <li>1 &le; <b>N</b> &le; min(1 000 000, <b>W</b> * <b>H</b>)</li>
32
+ <li>1 &le; <b>a</b>, <b>b</b>, <b>c</b>, <b>d</b> &le; <b>100</b></li>
33
+ <li> 0 &le; <b> X </b> &lt; <b> W </b></li>
34
+ <li> 0 &le; <b> Y </b> &lt; <b> H </b></li>
35
+ <p>&nbsp;</p>
2013/round1/dead_pixels.in ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 40
2
+ 4 4 2 2 1 0 2 1 2 3 4
3
+ 4 4 1 1 3 1 1 2 2 2 2
4
+ 6 10 3 2 2 0 0 5 4 3 2
5
+ 16 18 5 1 5 10 8 21 27 29 87
6
+ 14 15 12 4 4 3 5 84 74 53 68
7
+ 196 827 117 730 108 131 477 41 72 11 66
8
+ 703 687 125 343 321 68 78 38 8 2 66
9
+ 943 715 356 144 449 893 533 86 24 28 90
10
+ 192 223 29 170 28 25 108 89 74 40 51
11
+ 490 844 318 332 275 241 434 79 99 34 80
12
+ 1163 9027 94 86 1000000 1054 6993 92 90 59 19
13
+ 1078 5052 143 146 1000000 857 568 15 20 2 7
14
+ 9870 591 100 109 1000000 46 313 37 25 63 70
15
+ 6503 8478 146 197 1000000 332 8138 33 8 90 43
16
+ 5726 4567 144 121 1000000 454 3685 99 81 46 52
17
+ 4886 4367 95 87 1000000 3493 4363 2 66 19 64
18
+ 5134 2621 141 183 1000000 2309 282 36 56 66 26
19
+ 8497 2343 94 193 1000000 5999 1852 70 15 92 16
20
+ 4718 7077 134 115 1000000 3964 4597 7 20 29 77
21
+ 9883 7515 100 76 1000000 9567 1921 35 86 77 52
22
+ 35510 11125 1346 1407 395 35248 9485 18 91 26 9
23
+ 28557 13495 1138 1991 385 23252 10801 56 19 77 36
24
+ 21995 37911 1150 1245 833 47 23529 19 74 87 95
25
+ 24576 30148 1171 1922 740 19787 13047 34 74 34 11
26
+ 20133 29990 1305 1623 603 7664 19517 81 90 36 9
27
+ 39724 39430 20919 20227 3 7295 34728 28 46 33 14
28
+ 39491 39608 20414 20014 3 22564 17425 7 17 95 40
29
+ 39078 39880 20882 20735 3 22243 24336 53 36 6 40
30
+ 39843 39881 20522 20114 3 11897 5279 74 89 96 58
31
+ 39353 39838 20565 20767 3 35517 37854 90 60 17 84
32
+ 38850 37146 6 132 1443 28733 35729 1 38 55 58
33
+ 35277 38250 2 199 1349 28136 16549 49 90 40 96
34
+ 36598 39593 9 164 1449 27518 12034 65 2 51 34
35
+ 37637 35252 131 4 1326 1844 2265 72 38 3 79
36
+ 38095 39579 180 6 1507 11485 32227 86 32 39 26
37
+ 36478 39536 170 1 1442 22516 31242 4 70 37 6
38
+ 36402 39273 278 35 1000000 11371 25106 51 98 33 54
39
+ 39527 38179 294 327 1000000 12899 20050 56 52 99 46
40
+ 35728 35276 139 460 1000000 14745 27690 33 97 8 69
41
+ 39954 39461 443 17 1000000 34349 36388 60 98 69 44
2013/round1/dead_pixels.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ John's friend Peter purchases a new high resolution monitor with dimension
2
+ **W** * **H** where **W** is the number of pixels in each row (i.e. width) and
3
+ **H** is the number of pixels in each column (i.e. height).
4
+
5
+ However, there are **N** dead pixels on the monitor. The **i**-th dead pixel
6
+ is located at (**x**[**i**], **y**[**i**]). (0, 0) is the top-left pixel and
7
+ (**W** \- 1, **H** \- 1) is the bottom-right pixel. The locations of the dead
8
+ pixels could be generated by 6 given integers **X**, **Y**, **a**, **b**,
9
+ **c** and **d** by the following rules. If 2 pixels are at the same location,
10
+ they are considered the same. It is possible that there are less than **N**
11
+ **distinct** dead pixels.
12
+
13
+ * **x**[0] = **X**
14
+ * **y**[0] = **Y**
15
+ * **x**[**i**] = (**x**[**i** \- 1] * **a** \+ **y**[**i** \- 1] * **b** \+ 1) % **W** (for 0 < **i** < **N**)
16
+ * **y**[**i**] = (**x**[**i** \- 1] * **c** \+ **y**[**i** \- 1] * **d** \+ 1) % **H** (for 0 < **i** < **N**)
17
+
18
+ Peter connects his monitor to his computer and opens an image with dimension
19
+ **P** (width) * **Q** (height). How many unique positions can the image be
20
+ placed so that it can be displayed perfectly (i.e. all pixels of the picture
21
+ are shown on the monitor)? The image cannot be rotated.
22
+
23
+ ### Input
24
+
25
+ The first line contains an integer **T**, which is the number of test cases.
26
+ Then **T** test cases follow. Each test case contains 11 integers **W**,
27
+ **H**, **P**, **Q**, **N**, **X**, **Y**, **a**, **b**, **c**, **d**.
28
+
29
+ ### Output
30
+
31
+ For each of the test cases numbered in order from 1 to **T**, output "Case #",
32
+ followed by the case number (with 1 being the first test case), followed by ":
33
+ ", followed by an integer which is the number of different possible positions
34
+ for the poster.
35
+
36
+ ### Constraints
37
+
38
+ * 1 ≤ **T** ≤ 20
39
+ * 1 ≤ **W**, **H** ≤ 40 000
40
+ * 1 ≤ **P** ≤ **W**
41
+ * 1 ≤ **Q** ≤ **H**
42
+ * 1 ≤ **N** ≤ min(1 000 000, **W** * **H**)
43
+ * 1 ≤ **a**, **b**, **c**, **d** ≤ **100**
44
+ * 0 ≤ ** X ** < ** W **
45
+ * 0 ≤ ** Y ** < ** H **
46
+
2013/round1/dead_pixels.out ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 7
2
+ Case #2: 15
3
+ Case #3: 32
4
+ Case #4: 197
5
+ Case #5: 16
6
+ Case #6: 0
7
+ Case #7: 0
8
+ Case #8: 0
9
+ Case #9: 174
10
+ Case #10: 0
11
+ Case #11: 5143976
12
+ Case #12: 0
13
+ Case #13: 234800
14
+ Case #14: 137
15
+ Case #15: 0
16
+ Case #16: 7117142
17
+ Case #17: 0
18
+ Case #18: 0
19
+ Case #19: 0
20
+ Case #20: 18323862
21
+ Case #21: 51269087
22
+ Case #22: 35640189
23
+ Case #23: 186206173
24
+ Case #24: 63069325
25
+ Case #25: 58918133
26
+ Case #26: 96242184
27
+ Case #27: 18068400
28
+ Case #28: 86716522
29
+ Case #29: 187837304
30
+ Case #30: 236760710
31
+ Case #31: 1436707606
32
+ Case #32: 1341788941
33
+ Case #33: 1440614287
34
+ Case #34: 1321395055
35
+ Case #35: 1498870465
36
+ Case #36: 1435268809
37
+ Case #37: 1082989958
38
+ Case #38: 8231724
39
+ Case #39: 373470264
40
+ Case #40: 1202810198
2013/round1/security.html ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>You are designing a new encryption system that works in the following way:<p/>
2
+
3
+ <p>For server-client communication you need a key <strong>k</strong>, composed of <strong>m</strong> sections, each of length <strong>l</strong>, and the key consists only of lowercase characters in the set {a, b, c, d, e, f}. The server has a key <strong>k1</strong> and the client has a key <strong>k2</strong> where:<p/>
4
+
5
+ <ul>
6
+ <li>k1 = f(k). <strong>f</strong> is a function that receives a key and replace some random letters by ? indicating that those characters can be any lowercase letter of the set described before.</li>
7
+ <li>k2 = f(g(k)). <strong>g</strong> is a function that takes a key and produces a random permutation of its m sections. And <strong>f</strong> is the function defined above.</li>
8
+ </ul>
9
+
10
+ <p>For example: let m = 3, l = 2</p>
11
+ <ul>
12
+ <li>f('abacbc') = '?ba??c'</li>
13
+ <li>g('abacbc') = 'acbcab' (each section was moved one place to the left).</li>
14
+ </ul>
15
+
16
+ <p>Your task is given <strong>k1</strong> and <strong>k2</strong>, find key <strong>k</strong>. If there are several solutions, print the lexicographically smallest key. And if there is no solution at all, print "IMPOSSIBLE" (without the quotes).</p>
17
+
18
+ <h2>Input description:</h2>
19
+ <p>The first line has a single integer <strong>T</strong>, which corresponds to the number of test cases. <strong>T</strong> test cases follows: the first line of the test case corresponds to the integer <strong>m</strong>, the second line contains the string <strong>k1</strong> and the third line contains the string <strong>k2</strong>.</p>
20
+
21
+ <h2>Constraints:</h2>
22
+ <p>
23
+ <ul>
24
+ <li>T &le; 20</li>
25
+ <li>0 &lt; |k1| &le; 100</li>
26
+ <li>0 &lt; m &le; 50</li>
27
+ <li>|k2| = |k1|</li>
28
+ <li>It is guaranteed that m is always a divisor of |k1|</li>
29
+ <li>k1 and k2 consist of {a, b, c, d, e, f, ?}</li>
30
+ </ul>
31
+ <p/>
32
+
33
+ <h2>Output description:</h2>
34
+ <p>For test case <strong>i</strong>, numbered from <strong>1</strong> to <strong>T</strong>, output "Case #i: ", followed by the lexicographically smallest key or "IMPOSSIBLE".</p>
2013/round1/security.in ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 107
2
+ 2
3
+ abcd
4
+ c?ab
5
+ 3
6
+ ab?c?c
7
+ ac?c??
8
+ 3
9
+ ab?c?c
10
+ aabbdd
11
+ 2
12
+ aa
13
+ bb
14
+ 2
15
+ abcd
16
+ cdab
17
+ 50
18
+ ????????????????????????????????????????????????????????????????????????????????????????????????????
19
+ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
20
+ 50
21
+ ????????????????????????????????????????????????????????????????????????????????????????????????????
22
+ ffffffffaffffffffbffffafffffffcffffffdffffffbfffffffefffffdfffffffaffffffbffffffaffffffffcffffffffff
23
+ 46
24
+ abaccfcccdeefffeffffbbfccbbfbedaffbefcdcfafcfe
25
+ faefecaefbcffbffccfacffbfdfcfdefcdfbfcbbbeeacc
26
+ 15
27
+ dbfbcdebfabeaaafedfbfbecdddebebacffcbeacdaada
28
+ cdafbfbddfdaaeffdaebebfdfeaefcebcacabccabdfca
29
+ 26
30
+ debbafdfacdfeccedfaddfa?cf?adeeffeeceabccbdfdab?fbceefbabeadffffeabaaebccebbdb
31
+ faaba?debecceecabacfdadeeabeffbabdfdcdffeaaddccbfffebcedfeefbdbeadfbcdfabaaceb
32
+ 30
33
+ eccaebcfdbefcdccbacfcbabdcfedcbdddfffeacdfccdfdffbafecfecdabcf?eafddfdcbbfbafcfaaadcccaacd
34
+ ecceedcfacfadcfebaccdacbbebbefeaecdcebefecdcbfbabaacfdacdccdfccebfbabffdaffcdcbdfcbafbcbaf
35
+ 22
36
+ ececbdbabcdadfecaaeaaecdcfacbdabbfbebdaecdcb
37
+ cdcfecbdaabfecbd?eacaeeabecdcbdfbcecbdbadaab
38
+ 23
39
+ cceaeaeb?eafefaaeceedcddfdccecacceaeeafdecdbba
40
+ deefdddcbcccdaaaabecceecfbfdaf?eeaecacdfcefdec
41
+ 6
42
+ aecbfaabfbddbaddcadcdcedb?ebecefebddbbefbacffaebdacbfaaafbeabbcbaccbbcefddeefbcbceec
43
+ efddeefbcbceecfbeabbcbaccbbcaecbfaabfbddbacffaebdacbfaaaddcadcdcedbcebecefebddbbefba
44
+ 13
45
+ d?ffbbebdedebfffdabcddebfbabdbfbcfacaceefafaeacfcdbedfbadfbafcbebeefcccfeaecaf
46
+ faeccfeaedbffcbebefbcfacbfdcbadfcccffcafdbbffadadbdeaabcddebaceefadeffbbcdbedc
47
+ 39
48
+ cadebfbecfbdebfcabcbbfbfceadafeecedadec
49
+ ceadbdfcedfeafcbeabeefbcbbcbdbcce?feadf
50
+ 19
51
+ aacbdbafadbcffdcfdaccebcfcbc?afebaebcbbbbdbfbabdebcccddde
52
+ dccfebdaedbcccdeccffbaadbcbfeabbdaacaebbabffdcedfbfcfbaef
53
+ 41
54
+ ddcba?acadd?dcdbdbe?fcaeadaffbe?dfcf?cfbc
55
+ aacdffbddfdfcfdeaadecb?ecefadbbbbcacdc?cd
56
+ 36
57
+ ?feedbfcaabfeab?b???fddcfbfbdcaeeecf
58
+ ?b?ceffedfba?bdfffadbcefa?edeebaddbf
59
+ 7
60
+ aa?dfacfefdf?dbbefcaccebcccadfeccbbecbbdbecaadfacffaebe?cddedcaddbceacdeeffffacdacedcdfbdee
61
+ cda?edcdfbdeea?adfacfefdffdbbefcaccebccbceacdeeffff?dbec?adfacff?ebe?cddedcaddcadfeccbb?cbb
62
+ 28
63
+ fe?fccfdbf?edcaadbcfdee??bf?aef?aceacaaffbffbfefaedf?ceadded?aefbebbd?edffbfcc?ceaff
64
+ beddfffdeabfbbdebffa?ffbcfe?aadedafdafbffbdcafcccceaed?affbdcfd?aabaadefdeeb?ffc?edb
65
+ 7
66
+ b?bcb?bcacdefebdeaafeec?baebbebb?bada?ef?ab??cafd
67
+ ?cebaebcacdefedafefa?bebbfb?bdeaafebbccafdbcbcb?b
68
+ 26
69
+ abbdbaedabfccfafb?bedecefa
70
+ dbbcceebfbbef?fffebebbffdf
71
+ 44
72
+ ?fffebaafd?ebeadf?a?adfbfecb?fddbacdba?f?ddb
73
+ edbbefaefbb?eabdfbdadeeac?ffdfbf?babfcacafde
74
+ 27
75
+ ceaeddac?fabedffddecaafbeed
76
+ cdefdcfeafafaaecdffaaaeaccb
77
+ 41
78
+ ?dedfedbddee?cbbfba?dfbfb?dfcadb?acffdabd
79
+ baff?d?bcddde?ddadfdabbb?efff?fdcedceb?be
80
+ 13
81
+ bcffdeaeffecdebaeeccacbecdabdebbcbfedfcfdecfbcdfacef
82
+ ebf?aea?acdaeeccacdfcdaaffe?debedebcd?cadcefbcfcfecf
83
+ 19
84
+ dbffaba???ef?ccaedd?aefa?cbfcefe?efe?dab?becaf?ca?abafa??
85
+ fece?ebe?e?aabaaaabcc??e?abaeeef?d???affd?aedb??f?bfeedbf
86
+ 41
87
+ dcbeea?dffebddbd?bdf?f?bbabcac?eacee?ddbdc?cdbdd?ec??f?abfcdfffecefb?cbfbfbcfdabfa
88
+ db?ba?be?fcefa?dbfba?cecdcdedb?fdbdca?fefebfbdffb?cbacb?b??defdfad?ba??f?bbf?adc?d
89
+ 30
90
+ ebfefbbb?edafccbf?cf??ede?aaeb
91
+ fe?becd?ea?bbcbcbbebdfeebf?cdd
92
+ 47
93
+ cbbfbf?bfeba?fabefabbeddeccfcca?bdeccbbfdda?f?c
94
+ feadf?dbbeef?cbefdccccbccaf?eec?d?bfbdbdbabfbaa
95
+ 20
96
+ beeefd?cdfeacfb?fceecbfdfcbdd?be?d??dbdab?ecfcca?bcc?dfee?ff?adc?eadadcf??beeeaf
97
+ ?b?afcee??feeeafbeeedfeacbfddbbeaadce?febfe?b?ccfdacfea?adcfbc?eebfffccaf??d??bd
98
+ 23
99
+ ?ebaa?acba?aebcb?dd?acebadcfbaabd?dccd?cbbd?cc
100
+ bababcddcbccdc?a??cefff?faac?fa?adcbebbed?aaac
101
+ 9
102
+ addecbc??d??baffacacf?fcdcaefaf?befe?b??fce?dedbfef?be
103
+ ?cfbfce???dbffbefeaddecbf?a?fcc?fdf??affacd?aefafe?eb?
104
+ 8
105
+ cacdbfbbacbf??eacf??fdfdaecdebfeaeebfbaf?eadbafddc??aceb?bb?bdaa
106
+ aecedbfed?aaacefdababbaaa?adbabdcacdbfbbabaafdf?acbeaf?aceeb?b?a
107
+ 18
108
+ ?ffbefadfbeaf?ccdfbbafbdcbaa?dadeb?dabbeaaaeeaead?accb
109
+ c?ba?a?b?adea?fcbabad?ddbea?ffbefbbacdfabbfb?aeee?adda
110
+ 13
111
+ dbda???fef??fdcd?fbefb?ecc??ac?fbbbb?aeffee?dedcaffd?d?ccfba?dd?eebab???dbeffbbc?abcb?ddafd
112
+ ?de?cbaaeafb?bb?ddafefe?dddc?fdedcecbbbddd?ad?efddce?a?fbeaeffcffdfdccdcdabefbbabacbc?afbef
113
+ 16
114
+ baf?abe??aa????aceadaa??cdc???ceeebcefcadcaeec??
115
+ ?ace?ceeaadacbad?b?cbaceadc?fa?a?cd?ebcaeeaccc??
116
+ 7
117
+ ?deeafeac?add?d?fadeccaebaddfbebcdcecebada
118
+ ede?afcebacade?cae?acaa?baddfbed?daedadefa
119
+ 20
120
+ a?bbfaead?dec?abeedaaebefeafc?badeddddbaebdebbac?a?cdae?fd?bd??cb?aecaccccffdef?eb?e??b?cc?cfacf??be
121
+ b?dedaea?baaecabfdcbfe?beacfacebdeaabf?cccccfebdebdecbaddd?a?d???dcfcbaebe?bee?aeafceacd?eaf??fbacea
122
+ 9
123
+ abd?bc??eccf?eebc?cccaba?cdbc?baaff?ddffabebaaacf?ed?ff?efcfdd??e??afaa?cfda?eeaffdadfffd?cde?c?eba
124
+ ?cc?eccfbb?dbafddadfef?efcfdd?bebdc??cbc?baafcaebfaccb?dfddbfaadabdafaabcfcd?aaadffedff?eba?b?ceecc
125
+ 50
126
+ a?ccbce??dddcde?e?fbcfcbddfbb?d?bf?e?adeeeaeebb??ca?ee?eeecfdf?fc???bbf?ceeb?bbebe?c?eebff?adedbdffb
127
+ ???bd?dfadbae?eadd?cedbf??dfde??bb?dd??efbcfb??bafeedcfbbecdccce?bff?b??ffadaac?aebebcdeeba??efbe??b
128
+ 34
129
+ cdef??bdaaaaebcfbddefae?da?eeafced
130
+ efdeffecc?dbbea?ceacaaaadfabe??e?c
131
+ 8
132
+ ffb??bbc
133
+ bffbacbc
134
+ 39
135
+ ??aa?b??d?fbf??febe??faad?e?effdabafeecccaaae?dfefccffca?aacedfc?cecacaeebfc??
136
+ cbeeacfcabcefa??bafbccfde?daaadbacdeecaaa??cd?caebeea?aceeccaffaecbfedcc???bcc
137
+ 21
138
+ bbb?cfab?acbcbfcddfcb?bcfbdbae?badcdddefeffbefd?ed??fffcfddfd?daae?ea????c?f?dbbaeee
139
+ effbaeeecb?c??fca?fb?dfcbac???aea??d?d?fa?abbfbced?bdfda???bdce?fbdbefdfddefbbbdeddd
140
+ 35
141
+ ?eca?aefebcbbedebe?f?afbeacbbefbc?aa?bbffbbd??bacffe?ecbdffdeddfffb??f
142
+ ebebfeaeb?bffbbe?af??fcfc?fafdbb??cd?fbabebfbffb?ddfabcbefcabf??ffabb?
143
+ 36
144
+ c?dbd?efeffbfbaebbaffbec?effdaeacded
145
+ fbedbfcabccaeabccadedfcfffdefbeebedf
146
+ 18
147
+ eccfffccafabbddbeddf?abdffbdddceeff?
148
+ ffdfebcfccafffccfacebdbdcfdccebfaabd
149
+ 3
150
+ eaacceefdefdacfebbbeeedd
151
+ eaac?eefbbbeeedddefda?fe
152
+ 7
153
+ ccacfceecbebceafaddbdfdbebdde?affecdabeefebbfd?acbabbccf
154
+ ccadccfadcebeeaacbabfecafbddeadfdddbdfdbfeddafbefbbeadfa
155
+ 14
156
+ da?cfdc?cafaffcbffdcacabdcaacffdbcaadaccbdcfacadad?cdcd?ecabedddacecabeabadecdceecfebdcaf?adbddbbd
157
+ dacecabeabade?cabdcaadbddbbddaacfdcdecdcdecfaca?acbffdcaecabeddcffdbcad?afaff?ceecfebdcafcaadaccbd
158
+ 3
159
+ edbdfb?ecfbcdfaafcaeaedbafcbaac??ebacbe
160
+ edbdfb?ecfbadcbadcbfebacaefaafcaeaedbaf
161
+ 36
162
+ cfbaafcaabdaafaeafffeabbdfdddcbeadba
163
+ fdfcbaeebccaadddaadaabeffdf?aaafbbab
164
+ 20
165
+ edabdbdafae?aabebeca?ebbb?afefafdaebedeb
166
+ affecadaedbeabedbcffdbdbbaafbeeb?becebda
167
+ 38
168
+ ec?faebfebedbbbdeafacdcdfadeddfacadaafccedbe?debddabeadabdccafcdfbd?cacbfabc
169
+ afcbccdedafaddebabdafadacdcacabefaeabfbc?dbbafe?eccdccddaeebbdfafbcdbd??bfea
170
+ 47
171
+ daedcebbcdbdfafeacdabccbbcdceddcdefcbbcfedacdef
172
+ fccbefafacaabdcbfcaddddfbeeceeccedcaebedfefdefb
173
+ 27
174
+ d??b?c??cfabeebad??d??d?efabd???caf?a???b?????????bf??
175
+ f??ddbf?dbb??fa??edacae?aeda???ede??ed??ba?ae????b???f
176
+ 43
177
+ ??bcfedc?aff?f?c?d?????d??cef?e?f?ccf?dba?dd??bf??b?bbabc?a?becdeb?f??cc?aa?c??d??a?bc
178
+ bdaee??f?be?df?dbd??fa?d??cd??cccb???b?c?ff?bd??bea?d?d?b???bdbc?aeabffca??b?a?c?dffaa
179
+ 27
180
+ ?dd???ea???a?aadfade??d??fe?a??ecd????af??ccaaac??adb?
181
+ ?ab?ad??a???e?be????db????d?f?db??de?c???dcd?f??c?b??a
182
+ 26
183
+ ae?e??a?cb??f??a?d?d?aacadab??bba??a?dfaa?db?a?d?fc?
184
+ fdad?ccdbbad?e?efc????caca?adfc?bbf??d??ac?fecdbf?e?
185
+ 3
186
+ ?adeb?cd?e??cd?ede?bd?fbc?????cc?f?c?cb????add?fde?c?a
187
+ e?b?b?fad??f?e?cd??ad?????be??cddeded?d????c?e??c???fc
188
+ 10
189
+ dcaed?d?fef?d?cb?d?ab?d?d?caed??f??acac?deed?bfdafdcef?b?????dfbb?fa?f?a?dc??ebb
190
+ fac?af??ac?dd?cd??deaaee?efb?a???abe?deb?ede?cddaf??ef?ccbbfe?cefdce??d??dcceed?
191
+ 24
192
+ ?dfad?d?dabe?deab?e??e?acab?c?a???d???cc?????adc?f??fef???e?fbba??daa?ce?ef?ecefabb?d?e?a??fa???
193
+ f??c??ebbbe?a???badae?f??e?c?b?????bddea?fdafa??cf??ded?abbaa??eda????e??ea??f?????????ad?ead?c?
194
+ 42
195
+ ?????aeb?cb???e?d??e?bdce?e????a?f?b???aedda??fcc????fffcf?fcd??d?b??addd????a?eaeec
196
+ ?ac?d?ed?f??ec?d?bbd?fefa??abedeaa?ffaaac?ff?bdbec?f??a??efaedafe?ecadf??bfae??c??eb
197
+ 10
198
+ adbecb??e?bd??eefbfef??fefc?cea?a?a??a??
199
+ adbe?bbe??cbd???a?a?fb?ef??f?aee?e?????d
200
+ 26
201
+ ade?bd?ddaa??c?be?d?fbd????dedeb?a?bc?ee?ad?e?ebb?be
202
+ bde?cc?bbf?ac?a????de?eb?c?cdc??fdf?bc?fabedfa?aa??d
203
+ 1
204
+ ???bdff?cbd??d?aa???e??????????a??f???b???bcadf??c???
205
+ ??db?f?e?????d?a???a???d????dd??e?fc?e?d??b??d???c?fa
206
+ 11
207
+ bc?c??efdecff?b?ed?cd?
208
+ f?d?a?ccfe??e???fc?cf?
209
+ 19
210
+ ?f?e??????c?a???e?d?cb??aebded??cc?e?c????f??dfb???bd???e
211
+ ??cb?f?????b???f?faf?c?a??????d?d????af??????eefbd?e???fc
212
+ 14
213
+ e??d?cfbaadfbf?????c?bed??dbde?cb???fcdd?d
214
+ b????d?eed?fe??bbab?d?ce?bdc?becdc?dc?dd??
215
+ 18
216
+ ??dae?c?bc??c???a?fc??ab??????ce?d?a
217
+ fc????d?????ad?d??a???c?ce?cbcfab?ef
218
+ 2
219
+ ?cf?d?d??abfc??ed?bf??d??fbeb???e??ab?dd?deaaaed?d??ac?f
220
+ acf??e??ca?f?d?ad?bfc??e???e???e??baf???????a???d????c??
221
+ 26
222
+ ?d?d?e??c?fecbd??f??da?c??
223
+ ??f????????d????????c?c?d?
224
+ 12
225
+ ??bf?e??????f?be?b?fbee??c??????eedbcd??ee?b???d??ccf??a?ca???bdc?c?????
226
+ ?f??efd????????fa??a?ec??f?adceccc?eef??e?????d??f??acacd?f????fcecab??e
227
+ 18
228
+ ??e???e????bc??f??
229
+ ??c???f??f?c??????
230
+ 10
231
+ d?dc?c?fcc??edcb?abf????ba??f?
232
+ ?ed???d?e?aca??b??b??b???f?eec
233
+ 41
234
+ b?b?e??c??????be??a???eec???e????e????ee?
235
+ ce?de???ae??cf?bbe?a?e?c????fdec?c???fc?f
236
+ 16
237
+ ?ec??b?abcbafddbd???a?df?b?df???
238
+ edbad?e?a??af?c?caca?ad???e?bf?e
239
+ 37
240
+ b???dce??a??c?b??cba?dbcfff??a??abf??dc??c???ce?db?f???f??dad??fe????????e
241
+ ??aecbbc??d????c?d?cd??fbc??e?c?fced?bba??cfd???f??d?de?e?da?bdbd?b?cfffaf
242
+ 7
243
+ ??eda???c?a????ec?ffc?c??b?c???ee??fbdd?c?c?d??d?c??c?fdd??a?e??e?ecf?afa???f
244
+ ?be?a?fa??adcc?fc??cffdd?b??ec?c?d???ab?????e??e?fe???ffcfc??bcfc??fcb?ce?d?e
245
+ 30
246
+ d??d???d?c?fd?b?caa???ca??b?d?
247
+ ??f??b???bcdb??bc?????ddddfad?
248
+ 15
249
+ b?d?c?dc??d?dfe????afb?da??dfa?f?cd??e???e???
250
+ ?dcc??aa?df?daebadda?edcba?ac?efd?f??c?dcd?d?
251
+ 48
252
+ ccaa?????cdcdeccc?a?fc????dd?bc?d?ebe?????????c???d?ba?a?a???acf?bfedb??a?afc??b?e?????ddbb??a?d
253
+ ???ac??d??fe??c?b??aebd?d?f?d????b?bce???ae?????ab??a?????dbc?f??????ffb???a?deed??????????bee??
254
+ 14
255
+ ??f?de??c?f??d??f???aed?efdef???d?b??e??adcde?f?d??f??c?caebf?a??e?b?c?d?ffa?f?fc???
256
+ ??cdad?c????f?d?b????f?c??aaae???a?fa?d??dc?ca??e?ebd?cd?abfefd?f?a?c??f??????ae?e?c
257
+ 21
258
+ ?b??fe??cf?faa??bddae
259
+ ????da?a?e?b?faf??a?b
260
+ 22
261
+ fc?d?c?a?bbca?d?dffaaf
262
+ ???daea???fd?e?d??d?da
263
+ 25
264
+ e?f????ba???b???e?e???????a?f??????f??c????f?f??ff???????f????e?e?b????ac?e??de???db?a???a?aebbdb???
265
+ ??f?c??bb?????????????????b?b??????????b????be??fb?c?f?????ab??b???b????????f??ab??d????????????e???
266
+ 22
267
+ facfa?be?d??ec?b???a?ff??c?c?fc?e?d???a?a???
268
+ ??f?????a??d????d??e????be?bf??a?b?a???c?bf?
269
+ 48
270
+ ??ab?d?a??????a??????????????e???d?b???bcf?d????
271
+ ?????c?a?????ee???d?????????????????dba???f????d
272
+ 17
273
+ ?feaaacf??????eab??e??ab?d????e?c????e?d????e?a?f?dd?dc??f?e?e????cab??e??????cc??cf?
274
+ a???????????????bc???ba???b?????????f??b?a?fb?fe??d????f?????f?bb?e???????d?f?b?f??ee
275
+ 38
276
+ ?????????ca??bd?????????????b?a?c?d????cf?fdb??????f?f???cfea?b??f????????f?
277
+ fb????????f???f???????d?????a??????????????????bc?d?????d?????????????????f?
278
+ 34
279
+ ?df???????ef?c??bca???cdaa??eac??effaa??dd?d???a???eb?b????ea?cd?b??
280
+ c?cf???bbb??b?????e??b????fa????a?????a?fbb?????a?da??a?e?ca??c?b???
281
+ 23
282
+ ???c??ca??e???????d???d
283
+ ?d??f????eca??b?????d??
284
+ 12
285
+ ?dd???????eb?c??c????????b?cf????d??
286
+ fe??d???c????e???f???a???a??a???????
287
+ 13
288
+ a??????eb?a??????????f????
289
+ ???f??a????d???f???bb?e???
290
+ 4
291
+ ??ea?db?????ff?f?ca??a?e???af?b?e?e???f???d???c????fa?da?b?d?c??fabf?b?b
292
+ ???f?????debf???abea??f???dad????ec?d?fa?a?c??dd??????a??a?dc????fcf?dcb
293
+ 47
294
+ ecaecd??faccfdcae?c??eaedfdcffbbeffbedaeea?faac
295
+ eaacfceadddcfaaf?dacfefeed?b?ffefbdcfbac?eadeaa
296
+ 5
297
+ edccfeeadfcbccdcffacefd?f
298
+ efdddaffacadccfeeaddcbdbc
299
+ 36
300
+ fdfeef?a?fec?b?dd?cefbfaaecc?fcbbbbe
301
+ feaddeb?afdefeebcfcdfccfbceaffcabeb?
302
+ 1
303
+ ceb?abbdbecafeaafdefdfbadcfabcabaadeaffdcbac?cdbcbcfcefcffeba?dcfffcbaadffeaa?ebcfd
304
+ c?bdcbbbfecaffdafdeedfbddbfebcacaadcaafdcbabcedbcbffbdbcffcd?ddbfff??aadbffaa?eb?c?
305
+ 33
306
+ e??afbbcdbfcfab?adfadedcae?bc?bed
307
+ dfeafeabebadcddbba?ecdfbcefcebfbd
308
+ 41
309
+ edfaeadccdadfafefd?acfcdffefedeffddfecb?cafecfbde?cadcd?aaffffaec?ea?a?abe?dabfcfe
310
+ f?edadfdaffabafeddecacdfdcabaeabfbfdbacbeeefcdcadfcdfeefda?eedcdfadcfcbbcf?efdaadf
311
+ 22
312
+ dfecfcbfabbeaaef?ddadfbecada?fadcfbcafbefbabcbfebbfddb?aabfee?dfdba?cadbdbacdebcceaaccd?
313
+ fbabdddaca?aecdffcbfccdbdbfadfbecadbcfbcdfecaaefdebcafbeabbea?a?cbfeceaadbacbbfdd?acabfe
314
+ 23
315
+ ?eadffafd?dcbcbbafa?cbaddbbdffdafbafcc?bcdafdc
316
+ aadcad?bcdafadfeccafbcdbdbbfbbd?dadcffdbbdfffe
317
+ 32
318
+ eeafbebdee??cccefedfbaceadbfabaf
319
+ fcddbebcffdecea?efcebeeaebbbaafb
320
+ 39
321
+ bdabfaae?bdafc?c?aeffaabe?adbccdafcaedd
322
+ babbfabbfbcdbebdfbcfcccbdcacacaecebafae
2013/round1/security.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are designing a new encryption system that works in the following way:
2
+
3
+ For server-client communication you need a key **k**, composed of **m**
4
+ sections, each of length **l**, and the key consists only of lowercase
5
+ characters in the set {a, b, c, d, e, f}. The server has a key **k1** and the
6
+ client has a key **k2** where:
7
+
8
+ * k1 = f(k). **f** is a function that receives a key and replace some random letters by ? indicating that those characters can be any lowercase letter of the set described before.
9
+ * k2 = f(g(k)). **g** is a function that takes a key and produces a random permutation of its m sections. And **f** is the function defined above.
10
+
11
+ For example: let m = 3, l = 2
12
+
13
+ * f('abacbc') = '?ba??c'
14
+ * g('abacbc') = 'acbcab' (each section was moved one place to the left).
15
+
16
+ Your task is given **k1** and **k2**, find key **k**. If there are several
17
+ solutions, print the lexicographically smallest key. And if there is no
18
+ solution at all, print "IMPOSSIBLE" (without the quotes).
19
+
20
+ ## Input description:
21
+
22
+ The first line has a single integer **T**, which corresponds to the number of
23
+ test cases. **T** test cases follows: the first line of the test case
24
+ corresponds to the integer **m**, the second line contains the string **k1**
25
+ and the third line contains the string **k2**.
26
+
27
+ ## Constraints:
28
+
29
+ * T ≤ 20
30
+ * 0 < |k1| ≤ 100
31
+ * 0 < m ≤ 50
32
+ * |k2| = |k1|
33
+ * It is guaranteed that m is always a divisor of |k1|
34
+ * k1 and k2 consist of {a, b, c, d, e, f, ?}
35
+
36
+ ## Output description:
37
+
38
+ For test case **i**, numbered from **1** to **T**, output "Case #i: ",
39
+ followed by the lexicographically smallest key or "IMPOSSIBLE".
40
+
2013/round1/security.out ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: abcd
2
+ Case #2: abacac
3
+ Case #3: IMPOSSIBLE
4
+ Case #4: IMPOSSIBLE
5
+ Case #5: abcd
6
+ Case #6: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
7
+ Case #7: afafafafbfcfdfeffbfbfcfdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
8
+ Case #8: abaccfcccdeefffeffffbbfccbbfbedaffbefcdcfafcfe
9
+ Case #9: IMPOSSIBLE
10
+ Case #10: debbafdfacdfeccedfaddfaacfdadeeffeeceabccbdfdabafbceefbabeadffffeabaaebccebbdb
11
+ Case #11: IMPOSSIBLE
12
+ Case #12: ececbdbabcdadfecaaeaaecdcfacbdabbfbebdaecdcb
13
+ Case #13: IMPOSSIBLE
14
+ Case #14: aecbfaabfbddbaddcadcdcedbcebecefebddbbefbacffaebdacbfaaafbeabbcbaccbbcefddeefbcbceec
15
+ Case #15: IMPOSSIBLE
16
+ Case #16: cadebfbecfbdebfcabcbbfbfceadafeecedadec
17
+ Case #17: IMPOSSIBLE
18
+ Case #18: ddcbaaacaddadcdbdbebfcaeadaffbecdfcfecfbc
19
+ Case #19: afeedbfcaabfeababddffddcfbfbdcaeeecf
20
+ Case #20: aaadfacfefdffdbbefcaccebcccadfeccbbecbbdbecaadfacffaebeacddedcaddbceacdeeffffacdacedcdfbdee
21
+ Case #21: IMPOSSIBLE
22
+ Case #22: bcbcbabcacdefebdeaafeecebaebbebbfbadafefaabbccafd
23
+ Case #23: IMPOSSIBLE
24
+ Case #24: afffebaafdbebeadfbacadfbfecbefddbacdbaefeddb
25
+ Case #25: IMPOSSIBLE
26
+ Case #26: adedfedbddeeacbbfbaadfbfbadfcadbeacffdabd
27
+ Case #27: IMPOSSIBLE
28
+ Case #28: dbffabaaabefbccaeddaaefabcbfcefeeefefdababecafecababafaee
29
+ Case #29: IMPOSSIBLE
30
+ Case #30: ebfefbbbbedafccbfbcfcdededaaeb
31
+ Case #31: cbbfbfabfebaafabefabbeddeccfccaabdeccbbfddadfec
32
+ Case #32: beeefdacdfeacfbdfceecbfdfcbddbbeadfedbdabfecfccabbccedfeebffaadcfeadadcfbcbeeeaf
33
+ Case #33: IMPOSSIBLE
34
+ Case #34: addecbcafdfabaffacacfbfcdcaefaffbefefbaafceadedbfefebe
35
+ Case #35: IMPOSSIBLE
36
+ Case #36: affbefadfbeafbccdfbbafbdcbaaddadebadabbeaaaeeaeaddaccb
37
+ Case #37: IMPOSSIBLE
38
+ Case #38: bafdabecbaacaccaceadaafacdceeaceeebcefcadcaeecba
39
+ Case #39: IMPOSSIBLE
40
+ Case #40: afbbfaeadbdecbabeedaaebefeafcebadeddddbaebdebbaceaacdaebfdcbdcfcbaaecaccccffdefaebdeaabfccacfacfeabe
41
+ Case #41: IMPOSSIBLE
42
+ Case #42: aaccbceaadddcdeaeafbcfcbddfbbadabfaeaadeeeaeebbaacadeeaeeecfdfafcaedbbffceebabbebedcaeebffdadedbdffb
43
+ Case #43: cdefaabdaaaaebcfbddefaecdaceeafced
44
+ Case #44: ffbacbbc
45
+ Case #45: IMPOSSIBLE
46
+ Case #46: bbbdcfabbacbcbfcddfcbfbcfbdbaeabadcdddefeffbefdfedddfffcfddfdfdaaeaeaafbdcefedbbaeee
47
+ Case #47: IMPOSSIBLE
48
+ Case #48: ccdbdcefeffbfbaebbaffbecceffdaeacded
49
+ Case #49: IMPOSSIBLE
50
+ Case #50: eaacceefdefdacfebbbeeedd
51
+ Case #51: IMPOSSIBLE
52
+ Case #52: daacfdcdcafaffcbffdcacabdcaacffdbcaadaccbdcfacadadecdcdeecabedddacecabeabadecdceecfebdcafcadbddbbd
53
+ Case #53: IMPOSSIBLE
54
+ Case #54: cfbaafcaabdaafaeafffeabbdfdddcbeadba
55
+ Case #55: IMPOSSIBLE
56
+ Case #56: ecbfaebfebedbbbdeafacdcdfadeddfacadaafccedbeadebddabeadabdccafcdfbdacacbfabc
57
+ Case #57: IMPOSSIBLE
58
+ Case #58: daabacaacfabeebadaadaadaefabdaaecafaaeaebadbdbdeedbffa
59
+ Case #59: aabcfedcaaffafacadaaaaadaacefaeafaccfadbaaddaabfbdbdbbabcaabbecdebdfbdcceaaecbbdfcafbc
60
+ Case #60: addaaaeaaaaaaaadfadeaadaafeaaaaecdbabaafdbccaaacdbadbe
61
+ Case #61: aeaeaaaacbbbfcaaadadcaacadabecbbaccaedfaafdbfafddfcd
62
+ Case #62: aadebacdbeaacddededbdafbccaeaaccaffcecbabafaddafdeacda
63
+ Case #63: IMPOSSIBLE
64
+ Case #64: adfadadadabeadeabaebaeaacabbceacbadacfccbbeafadcdfcafefcdaeafbbadedaaaceeefaecefabbaddeaafafafda
65
+ Case #65: aaaaaaebacbaaaeadaaeabdceaeaabcaafabadfaeddaaffccfecafffcfefcdecdbbdfadddeedfabeaeec
66
+ Case #66: adbecbbeeabdaaeefbfefaafefcbceaaaaaadaaa
67
+ Case #67: adeabdaddaaaacabeadafbdcbcfdedebaacbcceefadcefebbfbe
68
+ Case #68: aadbdffecbdaadaaaaaaeaadaaaaddaaeafcaebdaabcadfaacafa
69
+ Case #69: IMPOSSIBLE
70
+ Case #70: afaeaaaaaacaaaaaeadacbaaaebdedafccaeccaaaffafdfbeefbdfbde
71
+ Case #71: IMPOSSIBLE
72
+ Case #72: aadaeacabcaacaaaaafcacabadadefcebdfa
73
+ Case #73: IMPOSSIBLE
74
+ Case #74: adadaeaacafecbdaafaadaacaa
75
+ Case #75: IMPOSSIBLE
76
+ Case #76: aaeaaaeaaaabcaafcf
77
+ Case #77: dedcacafccfaedcbaabfaeecbaadfe
78
+ Case #78: babaeaacaaaaaabeaaaaaaeecaacecccdedfffeef
79
+ Case #79: aecacbcabcbafddbdabfaadfebedfaea
80
+ Case #80: baaadceaaaaacabaacbaadbcfffaaaaaabfbadcbacadbceadbafaeafcfdadacfeadaedfcde
81
+ Case #81: IMPOSSIBLE
82
+ Case #82: daadaaadacafdabacaaaaacabbbddf
83
+ Case #83: badacadcaadadfedcddafbadaaadfaefdcdcceadaeedc
84
+ Case #84: ccaaaaaaacdcdecccaaafcaaaaddabcadaebeaaaaaaaaacaaadabaaaaaaaaacfabfedbaaaaafcafbceeeeeaddbbbaafd
85
+ Case #85: IMPOSSIBLE
86
+ Case #86: abaafeaacfafaaaabddae
87
+ Case #87: fcadacdadbbcaededffaaf
88
+ Case #88: eafaaaabaaaabaaaeaeaaaaaaaaafaaaaaafaacaaaafafaaffaaaaaaafaafbeceabaaaaacaebadebbadbbaadbaaaebbdbeaa
89
+ Case #89: facfaabeadaaecabaaaaaffaacacafcaeadaababaefa
90
+ Case #90: aaabadaaaaaaaaaaaaaaaaaaaaaaaeaaadabaaabcfadaaae
91
+ Case #91: afeaaacfaaaaaaeabaaeaaabadaaaaefcbbaaeadabaaeaaafbddadcaffbeaeaaafcabafeaeeabcccafcfb
92
+ Case #92: aaaaaaaaacaaabdaaaaaaaaaaaaabaaacadaaaacfafdbaaaaaafafaaacfeaabaafaaaaaadafb
93
+ Case #93: adfaaaaaaaefacaabcaaaacdaaaaeacaaeffaaaaddadaaaaaabebbbbcfbeabcdfbda
94
+ Case #94: aaacaacaaaeaaaaaaadabfd
95
+ Case #95: addaaaaaaaebacaacaaaaaaaabacfcfeadaf
96
+ Case #96: aaaaaaaebaaaaaaaabadafafea
97
+ Case #97: IMPOSSIBLE
98
+ Case #98: ecaecdaafaccfdcaeacddeaedfdcffbbeffbedaeeaffaac
99
+ Case #99: IMPOSSIBLE
100
+ Case #100: fdfeefaaafeccbdddecefbfaaeccffcbbbbe
101
+ Case #101: IMPOSSIBLE
102
+ Case #102: ebdafbbcdbfcfabeadfadedcaeebcfbed
103
+ Case #103: IMPOSSIBLE
104
+ Case #104: dfecfcbfabbeaaefdddadfbecadaafadcfbcafbefbabcbfebbfddbfaabfeecdfdbaccadbdbacdebcceaaccdb
105
+ Case #105: IMPOSSIBLE
106
+ Case #106: eeafbebdeebbcccefedfbaceadbfabaf
107
+ Case #107: IMPOSSIBLE
2013/round2/cake_cutting.html ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>"Happy birthday to you... Happy birthday to you... Happy birthday to Grovyle... Happy birthday to you..."</p>
2
+
3
+ <p>Today is Grovyle's birthday and he is going to invite his friends to his birthday party.
4
+ To have an awesome party, each of the attendants should get one piece of cake.
5
+ Your job is to help Grovyle invite as many friends as you can.
6
+ </p>
7
+
8
+ <p>
9
+ However, Grovyle's parents are very mean, and make him use the following rules when cutting his cake:
10
+ <li>There is only ONE cylindrical cake.
11
+ <li>Grovyle cuts the cake <b>N</b> times, each cut being perpendicular to the surface of the cake.
12
+ <li>The <b>i</b>-th cut is a broken line with <b>a</b>[<b>i</b>] vertices.
13
+ <li>The knife is only allowed to intersect the edge of the cylindrical cake at the start and end of the cut.
14
+ </p>
15
+
16
+ <p>
17
+ What is the maximum number of pieces Grovyle could get?
18
+ </p>
19
+
20
+ <h3>Input</h3>
21
+ <p>
22
+ The first line contains an integer <b>T</b>, <b>T</b> &le; 50, indicating the number of test cases.
23
+ Each test case begins with an integer <b>N</b>, 1 &le; <b>N</b> &le; 100, followed by <b>N</b> integers <b>a</b>[<b>i</b>], 0 &le; <b>a</b>[<b>i</b>] &lt; 400, which indicate the number of vertices in the <b>i</b>-th cut.
24
+ </p>
25
+
26
+ <h3>Output</h3>
27
+ <p>
28
+ For each test case, output "Case #i: " followed by the maximum number of pieces of cake Grovyle can cut.
29
+ </p>
2013/round2/cake_cutting.in ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 50
2
+ 3 0 0 0
3
+ 2 1 1
4
+ 2 1 2
5
+ 4 0 0 0 1
6
+ 4 2 2 2 2
7
+ 8 0 6 2 6 1 8 7 9
8
+ 8 2 0 2 3 7 5 9 2
9
+ 8 2 8 9 7 3 6 1 2
10
+ 8 9 3 1 9 4 7 8 4
11
+ 8 5 0 3 6 1 0 6 3
12
+ 25 2 20 16 1 15 15 14 27 26 5 16 9 13 17 24 15 12 15 14 27 14 14 3 20 7
13
+ 25 18 6 8 8 24 3 11 14 19 12 0 26 18 19 22 16 6 24 29 15 10 14 28 17 21
14
+ 25 17 2 27 12 22 26 1 20 26 1 15 29 4 29 10 9 21 7 27 11 21 5 9 7 27
15
+ 25 16 17 3 6 5 16 23 29 14 28 21 2 29 3 29 0 18 28 5 10 9 6 23 8 25
16
+ 25 26 21 1 5 29 28 14 8 1 20 13 10 14 4 24 4 17 26 3 21 17 25 9 16 22
17
+ 25 11 17 28 5 17 24 1 8 25 29 7 15 13 8 8 3 21 18 9 26 4 13 13 23 8
18
+ 25 26 10 4 28 18 18 9 27 17 6 14 3 0 23 20 29 22 5 4 0 5 29 14 16 9
19
+ 25 2 12 14 7 27 15 4 8 11 2 18 29 3 16 8 10 22 11 10 15 1 1 0 28 5
20
+ 25 0 26 4 6 12 5 8 16 12 8 14 27 12 14 0 6 2 29 9 10 8 11 3 11 21
21
+ 25 10 13 14 10 3 19 11 29 16 9 3 13 18 20 25 26 26 14 0 10 14 6 12 6 7
22
+ 50 45 56 79 18 87 12 48 72 59 9 36 10 42 87 6 1 13 72 21 55 19 99 21 4 39 11 40 67 5 28 27 50 84 58 20 24 22 69 96 81 30 84 92 72 72 50 25 85 22 99
23
+ 50 40 42 98 13 98 90 24 90 9 81 19 36 32 55 94 4 79 69 73 76 50 55 60 42 79 84 93 5 21 67 4 13 61 54 26 59 44 2 2 6 84 21 42 68 28 89 72 8 58 98
24
+ 50 36 8 53 48 3 33 33 48 90 54 67 46 68 29 0 46 88 97 49 90 3 33 63 97 53 92 86 25 52 96 75 88 57 29 36 60 14 21 60 4 28 27 50 48 56 2 94 97 99 43
25
+ 50 39 2 28 3 0 81 47 38 59 51 35 34 39 92 15 27 4 29 49 64 85 29 43 35 77 0 38 71 49 89 67 88 92 95 43 44 29 90 82 40 41 69 26 32 61 42 60 17 23 61
26
+ 50 81 9 90 25 96 67 77 34 90 26 24 57 14 68 5 58 12 86 0 46 26 94 16 52 78 29 46 90 47 70 51 80 31 93 57 27 12 86 14 55 12 90 12 79 10 69 89 74 55 41
27
+ 50 20 33 87 88 38 66 70 84 56 17 6 60 49 37 5 59 17 18 45 83 73 58 73 37 89 83 7 78 57 14 71 29 0 59 18 38 25 88 74 33 57 81 93 58 70 99 17 39 69 63
28
+ 50 22 94 73 47 31 62 82 90 92 91 57 15 21 57 74 91 47 51 31 21 37 40 54 30 98 25 81 16 16 2 31 39 96 4 38 80 18 21 70 62 12 79 77 85 36 4 76 83 7 59
29
+ 50 57 44 99 11 27 50 36 60 18 5 63 49 44 11 5 34 91 75 55 14 89 68 93 18 5 82 22 82 17 30 93 74 26 93 86 53 43 74 14 13 79 77 62 75 88 19 10 32 94 17
30
+ 50 46 35 37 91 53 43 73 28 25 91 10 18 17 36 63 55 90 58 30 4 71 61 33 85 89 73 4 51 5 50 68 3 85 6 95 39 49 20 67 26 63 77 96 81 65 60 36 55 70 18
31
+ 50 11 42 32 96 79 21 70 84 72 27 34 40 83 72 98 30 63 47 50 30 73 14 59 22 47 24 82 35 32 4 54 43 98 86 40 78 59 62 62 83 41 48 23 24 72 22 54 35 21 57
32
+ 80 115 247 171 26 19 218 201 203 153 183 157 209 228 56 47 220 84 58 84 198 241 126 148 215 52 171 189 59 6 10 16 224 109 39 0 128 109 53 81 114 88 239 176 67 147 223 37 231 32 122 31 125 100 179 90 4 100 131 63 107 244 181 81 103 220 183 232 181 237 165 46 75 154 222 142 51 47 32 134 181
33
+ 80 6 165 57 208 95 249 212 47 233 26 154 227 59 87 182 132 21 16 63 110 182 211 185 86 35 180 240 83 64 226 116 70 142 25 28 89 25 240 136 110 118 143 87 178 82 121 60 205 138 225 65 70 187 103 8 222 33 100 157 97 77 126 19 71 151 149 160 28 139 148 138 110 143 77 140 226 199 52 181 87
34
+ 80 27 99 157 66 202 17 141 235 118 48 184 195 26 55 16 178 204 28 58 93 28 197 55 172 24 195 0 75 247 33 162 127 132 171 193 84 189 84 171 159 235 207 104 11 12 222 41 216 102 100 162 232 149 217 154 173 15 6 101 114 40 13 241 172 37 37 109 78 121 30 237 106 90 91 220 102 165 11 69 17
35
+ 80 111 83 101 112 50 6 138 167 114 239 32 154 104 125 179 141 162 38 219 136 170 206 94 10 149 64 215 64 76 136 183 39 219 35 152 121 143 40 39 109 131 173 14 235 48 45 127 63 83 198 199 105 155 43 218 156 210 183 73 36 171 108 177 140 245 181 11 240 73 50 100 204 75 114 42 124 159 169 39 94
36
+ 80 219 238 51 226 133 19 133 93 54 206 231 225 166 11 217 162 192 229 152 118 131 2 174 207 218 216 183 127 237 222 73 207 62 125 183 47 246 168 141 153 226 224 230 143 235 198 55 30 29 59 148 160 62 174 219 30 141 152 10 230 226 83 39 140 208 223 188 57 243 181 210 220 155 190 113 141 138 20 171 167
37
+ 80 79 171 180 243 95 149 24 88 154 136 69 232 219 210 123 30 183 163 87 29 94 149 249 101 89 214 242 80 86 15 99 165 186 131 11 134 133 137 222 37 23 143 19 242 104 244 124 139 9 63 168 103 212 19 205 154 233 49 234 69 65 185 87 103 169 200 237 52 87 62 89 110 205 210 204 161 57 79 153 66
38
+ 80 142 71 22 105 193 79 111 28 128 197 200 45 132 37 149 51 89 136 103 176 198 44 36 6 107 92 167 164 171 70 230 166 244 104 123 187 183 234 67 62 181 17 209 165 156 108 69 245 245 172 171 45 69 59 51 176 152 71 90 175 243 172 91 89 27 66 128 62 50 196 124 83 213 186 249 120 44 68 115 141
39
+ 80 92 139 187 13 198 90 189 202 13 131 128 7 54 71 96 183 138 225 245 40 171 222 226 134 158 225 106 202 145 222 196 89 111 133 103 161 75 42 216 89 174 94 96 80 17 44 13 7 19 110 150 42 82 126 29 240 203 135 45 98 107 241 187 70 226 40 84 51 83 50 242 109 246 190 189 13 235 54 123 106
40
+ 80 164 23 1 99 1 30 89 204 165 236 52 125 79 91 47 157 234 131 61 169 181 53 28 177 244 69 43 81 123 18 187 139 143 188 238 144 70 180 98 236 18 2 213 98 195 10 5 179 142 66 98 175 222 228 103 216 47 248 47 22 16 86 162 159 127 150 53 197 182 3 35 201 107 248 49 154 111 156 84 3
41
+ 80 75 34 178 47 13 133 115 60 131 14 185 147 100 97 158 79 99 63 129 134 66 164 85 25 15 236 180 126 142 116 129 69 2 159 116 15 145 83 178 26 97 113 26 50 62 36 129 13 100 8 147 166 25 232 44 40 70 76 18 65 44 249 134 46 158 103 62 53 186 92 182 34 57 60 84 119 96 65 234 196
42
+ 100 324 182 65 251 116 161 143 237 187 261 202 381 160 88 279 220 341 93 124 228 335 108 362 142 270 396 163 266 211 100 115 87 234 132 290 350 293 33 139 80 294 293 13 54 382 244 275 323 338 351 151 273 11 65 368 281 13 83 99 177 135 214 264 369 346 107 272 191 140 11 223 387 257 236 393 239 81 220 114 371 171 218 196 134 283 164 367 297 200 67 74 335 233 290 257 132 349 129 323 90
43
+ 100 92 147 29 349 335 22 140 368 243 255 339 366 25 136 53 260 252 20 157 4 87 183 340 321 26 197 5 327 278 328 369 370 27 398 320 363 21 60 283 216 267 223 182 292 311 235 153 163 208 262 168 295 398 60 168 376 209 173 303 87 54 273 57 81 223 329 396 244 342 280 12 209 55 147 54 366 334 159 81 142 373 201 38 371 213 158 299 22 284 155 61 290 380 71 323 203 0 320 0 342
44
+ 100 152 12 104 207 159 158 125 94 317 158 236 290 360 226 214 173 337 65 148 221 220 209 63 200 232 386 4 233 258 356 127 10 368 231 169 128 341 246 174 258 5 10 101 365 189 267 90 126 332 238 299 105 0 362 257 232 348 261 17 207 169 97 169 138 328 339 218 270 185 392 80 142 354 133 107 143 0 150 221 285 388 120 390 340 34 247 125 383 61 94 142 230 191 263 320 120 154 138 342 292
45
+ 100 130 22 34 85 108 94 180 108 244 2 345 184 122 287 125 157 135 202 92 148 296 186 330 40 49 251 112 156 389 54 48 72 28 82 157 88 176 337 197 20 339 94 205 14 382 282 123 69 36 215 217 284 353 99 324 354 350 36 110 292 42 158 364 23 241 121 111 369 10 260 390 302 355 147 316 289 381 39 358 17 206 175 301 111 274 178 65 177 166 176 69 161 334 33 136 127 106 199 97 116
46
+ 100 60 39 370 367 186 286 208 167 277 166 136 35 293 37 146 119 167 212 296 334 340 317 95 274 350 231 2 8 30 51 125 42 90 47 361 276 334 169 395 163 335 131 151 180 120 297 300 288 61 196 174 1 114 269 228 16 52 182 25 82 233 102 77 323 149 390 151 35 160 146 199 47 229 302 228 349 199 128 189 213 276 363 166 390 184 394 359 236 176 384 271 9 38 300 284 139 290 35 175 50
47
+ 100 181 326 50 362 228 278 264 379 358 53 144 234 369 311 177 105 257 136 342 34 72 165 395 110 65 232 249 307 267 376 358 1 302 360 363 82 238 227 14 196 233 158 30 154 69 207 259 327 295 201 313 367 318 260 29 335 92 231 243 312 207 153 313 62 113 228 96 351 56 110 99 241 269 81 395 290 289 254 169 136 8 82 104 326 295 133 214 387 364 57 251 124 210 164 138 323 393 234 226 1
48
+ 100 345 325 194 166 6 189 56 247 395 226 384 3 260 40 282 155 173 48 95 90 105 346 166 267 63 304 190 8 90 368 361 35 293 155 201 251 344 210 51 291 388 35 247 248 75 81 356 200 129 51 242 234 349 360 101 364 264 243 372 355 211 333 342 56 40 96 259 336 258 310 228 246 297 75 94 324 156 50 125 285 53 319 71 355 280 124 319 96 367 244 3 130 129 346 186 170 394 45 58 252
49
+ 100 358 386 398 355 363 394 380 371 397 357 358 350 378 379 357 358 353 379 357 372 375 360 352 354 358 390 376 352 386 385 356 396 373 354 351 387 351 383 360 398 392 369 350 371 350 358 381 356 387 388 378 362 351 383 368 359 373 395 364 361 382 372 357 357 379 361 394 380 394 357 378 387 376 378 360 378 386 391 384 375 382 365 389 383 398 358 394 373 355 360 385 389 383 394 396 362 355 393 392 350
50
+ 100 390 370 379 398 390 399 376 387 382 391 384 384 378 374 379 378 394 394 391 389 396 378 390 389 383 396 373 388 389 385 370 371 377 371 399 398 392 376 377 375 389 383 389 389 387 399 397 373 385 380 384 381 389 374 371 394 393 396 374 382 382 397 376 381 398 375 371 391 373 370 396 384 384 377 395 393 398 392 397 383 395 373 387 384 378 380 370 371 376 374 375 388 393 381 392 392 379 385 375 374
51
+ 100 396 393 391 392 390 396 395 391 399 394 394 396 398 391 390 398 391 392 399 398 398 396 398 392 390 392 394 399 398 391 395 396 394 396 398 396 393 395 397 394 392 394 390 392 397 392 390 391 396 391 399 394 399 399 396 399 394 392 390 392 393 396 398 399 392 398 396 397 393 395 393 395 399 395 399 397 399 399 390 395 392 391 390 392 390 396 393 396 399 394 398 394 390 398 394 394 398 392 394 392
2013/round2/cake_cutting.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Happy birthday to you... Happy birthday to you... Happy birthday to
2
+ Grovyle... Happy birthday to you..."
3
+
4
+ Today is Grovyle's birthday and he is going to invite his friends to his
5
+ birthday party. To have an awesome party, each of the attendants should get
6
+ one piece of cake. Your job is to help Grovyle invite as many friends as you
7
+ can.
8
+
9
+ However, Grovyle's parents are very mean, and make him use the following rules
10
+ when cutting his cake:
11
+
12
+ * There is only ONE cylindrical cake.
13
+ * Grovyle cuts the cake **N** times, each cut being perpendicular to the surface of the cake.
14
+ * The **i**-th cut is a broken line with **a**[**i**] vertices.
15
+ * The knife is only allowed to intersect the edge of the cylindrical cake at the start and end of the cut.
16
+
17
+ What is the maximum number of pieces Grovyle could get?
18
+
19
+ ### Input
20
+
21
+ The first line contains an integer **T**, **T** ≤ 50, indicating the number of
22
+ test cases. Each test case begins with an integer **N**, 1 ≤ **N** ≤ 100,
23
+ followed by **N** integers **a**[**i**], 0 ≤ **a**[**i**] < 400, which
24
+ indicate the number of vertices in the **i**-th cut.
25
+
26
+ ### Output
27
+
28
+ For each test case, output "Case #i: " followed by the maximum number of
29
+ pieces of cake Grovyle can cut.
30
+
2013/round2/cake_cutting.out ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 7
2
+ Case #2: 7
3
+ Case #3: 10
4
+ Case #4: 14
5
+ Case #5: 63
6
+ Case #6: 1051
7
+ Case #7: 682
8
+ Case #8: 1006
9
+ Case #9: 1342
10
+ Case #10: 481
11
+ Case #11: 73970
12
+ Case #12: 84716
13
+ Case #13: 83486
14
+ Case #14: 78656
15
+ Case #15: 80651
16
+ Case #16: 71303
17
+ Case #17: 72060
18
+ Case #18: 45803
19
+ Case #19: 44303
20
+ Case #20: 63953
21
+ Case #21: 2812106
22
+ Case #22: 3290995
23
+ Case #23: 3438853
24
+ Case #24: 2886103
25
+ Case #25: 3376201
26
+ Case #26: 3475666
27
+ Case #27: 3311551
28
+ Case #28: 3186650
29
+ Case #29: 3257728
30
+ Case #30: 3337336
31
+ Case #31: 52516036
32
+ Case #32: 47244220
33
+ Case #33: 43082563
34
+ Case #34: 47672890
35
+ Case #35: 73732456
36
+ Case #36: 54637991
37
+ Case #37: 50205370
38
+ Case #38: 49955170
39
+ Case #39: 45063431
40
+ Case #40: 31343563
41
+ Case #41: 225027705
42
+ Case #42: 213924470
43
+ Case #43: 203465078
44
+ Case #44: 155734976
45
+ Case #45: 185657015
46
+ Case #46: 229933490
47
+ Case #47: 212850228
48
+ Case #48: 698389451
49
+ Case #49: 741991703
50
+ Case #50: 782437661
2013/round2/permutations.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>In this problem you need to count number of possible permutations <strong>p</strong> of the first <strong>N</strong> integers,
2
+ given <strong>N-1</strong> constraints of the form <strong>p<sub>i</sub> &lt; p<sub>j</sub>.</strong><p>
3
+
4
+ <h2>Input</h2>
5
+ <p>The first line contains an integer <strong>T</strong>, <strong>T</strong> &le; 20, followed by <b>T</b> test cases. Each test case begins with an integer <strong>N</strong>, <strong>N</strong> &le; 1,000, which is the number of integers in the permutation. The next <strong>N - 1</strong> lines each contain a single constraint in the following format: "<b>i</b> <b>sign</b> <b>j</b>", where 0 &le; <strong>i</strong>, <strong>j</strong> &le; <strong>N - 1</strong> and <strong>sign</strong> is either "<strong>&lt;</strong>" or "<strong>&gt;</strong>", which denotes whether the <b>i</b>-th element of the permutation should be less than or greater than the <b>j</b>-th element.</p>
6
+
7
+ <p>It is guaranteed that it is not possible to partition indices into two disjoint sets A and B such
8
+ that there is no constraint involving elements from both A and B.</p>
9
+
10
+ <h2>Output</h2>
11
+ <p>For each test case, output one single line with the number of permutations that satisfy all the
12
+ constraints, following the output format shown in the example. The answer may be very large, so you should give the result modulo <strong>1,000,000,007</strong>.</p>
2013/round2/permutations.in ADDED
The diff for this file is too large to render. See raw diff
 
2013/round2/permutations.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ In this problem you need to count number of possible permutations **p** of the
2
+ first **N** integers, given **N-1** constraints of the form **pi < pj.**
3
+
4
+ ## Input
5
+
6
+ The first line contains an integer **T**, **T** ≤ 20, followed by **T** test
7
+ cases. Each test case begins with an integer **N**, **N** ≤ 1,000, which is
8
+ the number of integers in the permutation. The next **N - 1** lines each
9
+ contain a single constraint in the following format: "**i** **sign** **j**",
10
+ where 0 ≤ **i**, **j** ≤ **N - 1** and **sign** is either "**<**" or "**>**",
11
+ which denotes whether the **i**-th element of the permutation should be less
12
+ than or greater than the **j**-th element.
13
+
14
+ It is guaranteed that it is not possible to partition indices into two
15
+ disjoint sets A and B such that there is no constraint involving elements from
16
+ both A and B.
17
+
18
+ ## Output
19
+
20
+ For each test case, output one single line with the number of permutations
21
+ that satisfy all the constraints, following the output format shown in the
22
+ example. The answer may be very large, so you should give the result modulo
23
+ **1,000,000,007**.
24
+
2013/round2/permutations.out ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Case #1: 1
2
+ Case #2: 1
3
+ Case #3: 4
4
+ Case #4: 6
5
+ Case #5: 1
6
+ Case #6: 764344399
7
+ Case #7: 450800465
8
+ Case #8: 898996475
9
+ Case #9: 226501413
10
+ Case #10: 598446060
11
+ Case #11: 923158588
12
+ Case #12: 311325632
13
+ Case #13: 221028522
14
+ Case #14: 976696890
15
+ Case #15: 398503520
16
+ Case #16: 702516736
17
+ Case #17: 733724736
18
+ Case #18: 402844675
19
+ Case #19: 554181637
20
+ Case #20: 407752774
21
+ Case #21: 176111360
22
+ Case #22: 578419130
23
+ Case #23: 783121995
24
+ Case #24: 110121107
25
+ Case #25: 571247919
26
+ Case #26: 333381309
27
+ Case #27: 957059657
28
+ Case #28: 74430116
29
+ Case #29: 752981215
30
+ Case #30: 605744922
31
+ Case #31: 65130122
32
+ Case #32: 11050467
33
+ Case #33: 369696022
34
+ Case #34: 386169919
35
+ Case #35: 781872677
36
+ Case #36: 286188750
37
+ Case #37: 603564700
38
+ Case #38: 682609757
39
+ Case #39: 713083365
40
+ Case #40: 954131631
41
+ Case #41: 379666854
42
+ Case #42: 316070471
43
+ Case #43: 14401757
44
+ Case #44: 158451693
45
+ Case #45: 974926246
46
+ Case #46: 373588671
47
+ Case #47: 249001229
48
+ Case #48: 348656138
49
+ Case #49: 371822065
50
+ Case #50: 730948093
51
+ Case #51: 339234304
52
+ Case #52: 472477039
53
+ Case #53: 244180714
54
+ Case #54: 471613032
55
+ Case #55: 740830151
56
+ Case #56: 230510055
57
+ Case #57: 373748783
58
+ Case #58: 408060198
59
+ Case #59: 85824300
60
+ Case #60: 892144422
2013/round2/roboelection.html ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>In the not so distant future the world is populated by robots and ruled by an evil robot emperor. Every robot in the world can be identified by a unique numeric ID, and the list of all the existing robot IDs is easily accessible to everyone.
2
+ One day the emperor decided to call for a general election to preserve an illusion of democracy. He set it up in the following way:<p>
3
+ <ul>
4
+ <li> - Every robot can cast at most one vote per round of voting and the votes are anonymous.</li>
5
+ <li> - The only option on the ballot is the vote for reelection of the emperor.</li>
6
+ <li> - If at least <strong>P</strong> percent of the population cast votes for the emperor he becomes reelected for the next millennium.</li>
7
+ <li> - Otherwise the emperor declares the vote void, disassembles <strong>K</strong> robots with the lowest ID numbers (who he finds to be the most rebellious), and then if there are any functional robots left he restarts the whole process.</li>
8
+ </ul>
9
+ <p>
10
+ All the robots are perfectly logical but also rather lazy and prone to procrastination. That's why after figuring out the plan of the emperor, they will abstain from voting unless they have to vote to survive the election (including this round and all later rounds). If they will die whether or not they vote, they will vote in the hope that the emperor will spare them. (He won't, because he's evil!).
11
+ </p>
12
+ <h2>Problem</h2>
13
+ <p>
14
+ Given <strong>N</strong> - the initial population size, <strong>K</strong> - the number of robots disassembled after an unsuccessful vote and <strong>P</strong> - the required percentage of votes.</p><p> Compute the number of times the vote will take place. </p>
15
+
16
+ <h2>Input</h2>
17
+ <p>The first line contains the number of test cases <strong>T</strong>, where <strong> 1 &le; T &le; 100 </strong></p>
18
+ <p>Each case is a single line with three space-separated integers <strong>N</strong> <strong>K</strong> <strong>P</strong></p>
19
+ <p>0 &lt; <strong>K</strong> &le; <strong>N</strong> &le; 1,000,000,000,000 <br/>
20
+ 0 &lt; <strong>P</strong> &le; 100</p>
21
+
22
+ <h2>Output</h2>
23
+ <p>For test case <strong>i</strong>, numbered from <strong>1</strong> to <strong>T</strong>, output "Case #i: ", followed by a single integer, the number of times the emperor will have to call a vote before getting reelected.
24
+
25
+ <h2>Example</h2>
26
+ <p>In the first case we have three robots. Two of them are facing disassembly, so they will vote for the emperor. The third robot will survive even if he abstains in the first round, so he doesn't vote. But two out of three is not enough to reach the 75% minimum, so the election proceeds to a second round. The election ends when the single remaining robot casts a vote for the emperor.</p>
27
+ <p>In the second case again two robots are in immediate danger, but the next two robots are forced to vote as well, otherwise they would end up in the same situation as in the first example case. Now with the 4 out of 5 casting the vote the election successfully ends.</p>
28
+
29
+