SPOJ Challenge
SPOJ Challenge
SPOJ Challenge
challenge problemset
Editors:
Roman Sol
Micha Maafiejski
Adrian Kosowski
(Tjandra Satria
Gunawan)(???)
Francky
.:: Debanjan ::.
XeRoN!X
HWK
Bin Jin
[Trichromatic] XilinX
cegprakash
Devil D
Mostafa 36a2 (Al3ayesh)
Spooky
Govind Lahoti
Jimmy Tirtawangsa
ukasz Kuszner
A@k@sh Joh@ri
Vimal
Thomas Dybdahl Ahle
Michael Suchacz
Konrad Piwakowski
Gogu Marian
Yandry Perez
Jander
Jargon
legrand
Kawmia Institutes
Thanh-Vy Hua
Jared Deckard
Michael Mudge
Adam Dzedzej
Better late than never
!!!
Pawel Gawrychowski
Aditya Pande
Maxim Sukhov
Race with time
Therapist
Ruslan Sennov
Krzysztof Kluczek
Tony Beta Lambda
Duc
Preface
This electronic material contains a set of algorithmic problems, forming the archives of the Sphere
Online Judge (http://www.spoj.com/), challenge problemset. The document can be accessed at the
following URLs:
in PostScript format: http://www.spoj.com/problems/challenge.ps
in Portable Document Format: http://www.spoj.com/problems/challenge.pdf
These resources are constantly updated to synchronise with the ever-changing hypertext version of the
problems, and to include newly added problems. If you have obtained this document from another
source, it is strongly recommended that you should download the current version from one of the
aforementioned URLs.
Disclaimer from the Editors. Despite our best efforts, it is possible that this document contains errors or that some of the
content differs slightly from its original hypertext form. We take no responsibility for any such faults and their
consequences. We neither authorise nor approve use of this material for any purpose other than facilitating problem solving
at the Sphere Online Judge site; nor do we guarantee its fitness for any purpose whatsoever.
The layout of the problems in this document is the copyright of the Editors named on the cover (as determined by the
appropriate footers in the problem description). The content is the copyright of the respective Editor unless the copyright
holder is otherwise stated in the resource section. The document as a whole is not protected by copyright, and fragments
of it are to be regarded independently. No responsibility is taken by the Editors if use or redistribution of this document
violates either their or third party copyright laws. When referring to or citing the whole or a fragment of this document,
please state clearly the aforementioned URLs at which the document is to be found, as well as the resources from which the
problems you are referring to originally came.
Remarks concerning this document should be sent to the following e-mail address: contact@spoj.com.
Table of Contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
53. Kamil
Problem code: KAMIL
Some kids cannot pronounce all letters, some of them they sometimes pronounce correctly and
sometimes incorrectly. Kamil sometimes says T instead of K, but he never says K instead of T.
Similarly he sometimes says D instead of G. Instead of R he sometimes says L and sometimes F. Of
course it happens that he pronounces the letter correctly. Kamils father always thinks how many
words can mean the word spoken by his son (it doesnt matter if they are real English words).
Task
Write a program which
reads from standard input the words spoken by Kamil
counts how many different words can that mean
writes the outcome on standard output
Input
Ten test cases (given one under another, you have to process all!). Every test case is a single line - a
word spoken by Kamil. Only 26 capital leters are used. The length of the word is at most 20.
Output
For every testcase write an integer in a single line with a single integer, denoting the number of words
which Kamils word can mean.
Score
The score awarded to your program is the number of bytes the source code you submit. The fewer
points you score, the better. Submissions are not allowed to exceed 256 bytes.
Remark. It may turn out impossible to solve this problem in some languages.
Example
Input:
FILIPEK
[and 9 test cases more]
Output:
4
[and 9 test cases more]
Input
The first line of input contains a single positive integer t <= 1000, the number of test cases. Each test
case begins with the number of shops in the city 1 <= n <= 1000 and the deadline 1 <= m <= 5000.
Then the following n lines consist of four integers x i y i a i b i c i each, describing the position and the
parameters of the function for food availability of the i-th shop. At the end of every test case comes a
line with two integersp q (between 0 and 250), corresponding to the x and y coordinates of the position
of Johnnys house.
All the input data are integers.
Output
Process all test cases. The correct output for the i-th test case takes the following form:
i [the number of the test case, in the input order]
s m [s is the number of the target shop and m > 0 is the number of minutes spent in it].
At the end of the series of moves you should always write a line conisting of two zeros (0 0).
All the output data should be integers.
Scoring
The score of your program is the total amount of food that Johnny bought (summed over all the
testcases in which he managed to come back home before the deadline).
Example
Input
4
2 20
0 0 100 5 5
10 0 200 10 10
5 0
2 20
0 0 180 15 10
10 0 200 20 10
5 0
4 101
0 0 1000 20 5
20 0 200 1 5
0 20 5000 200 5
20 20 300 5 10
10 10
1 15
1 0 10 1 5
5 0
Output
1
2 10
0 0
2
1 10
0 0
3
3 5
4 10
2 1
0 0
4
1 5
0 0
Score
Score = 1261
Task
We are not asking you to implement the Solovay-Strassen algorithm, this would be far too easy :).
Instead, try to find values of n, for which the output of the algorithm would be "n is composite
(detected at attempt 1)", "n is composite (detected at attempt 2)", and so on. Write out as many of these
values as you can in consecutive lines, and try to keep them as small as possible.
Scoring
The score awarded to your program is the total of all points given for its individual lines.
The i-th line output by your program should contain exactly one positive odd integer n>2 of no more
than 500 decimal digits. If Solovay-Strassen(n) yields the answer "n is composite (detected at attempt
i)", you will receive i/log 10 n points for this line, if not - your program will be considered incorrect.
Output 0 if you dont want a line to be assessed. Only the first 1000 lines of output are taken into
account.
Example
A program outputing:
0
0
561
Input
The first line of input contains a single integer n<= 10000 denoting the number of sweet packets
Johnny has bought. In each of the next n lines a single positive integer is given, describing the weight
of the respective packet (the weight is an integer value never exceeding 10 14 ).
Output
In separate lines, output the numbers of the packets which Johnny should carry in his left hand.
Assume packets are numbered in the input order from 1 to n.
Scoring
Your program shall receive log 10 (s/(|d|+1)) points, where s is the total weight of all parcels, while d
denotes the difference in weight between the load carried in Johnnys left and right hand.
Example
For the sample input:
3
5
8
4
a program outputting:
2
3
10
11
12
13
14
15
Here we will deal with a generalized version of the above puzzle. You should write a program that
given some initial state of the nxn board finds a sequence of moves that transforms it so that in the i-th
row there are tiles with numbers i*n+1,i*n+2,...,i*n+n (from left to right) - with the exception of the
lower right corner where the hole should be. The less moves you use, the more points you get.
Input
The first line of input contains the number of test cases c (c<=200). Then c test cases follow, each of
them begins with a line with a single integer n (3<=n<=10) in it. The next n lines describe the initial
state of the board - the i-th line consists of exactly n integers describing the i-th row. The position of
the hole is indicated by 0.
Output
For each test case output one line - the found sequence of moves. Write D to move the hole down,
U to move it up, R to move it right and L to move it left. You shouldnt use more than 10000
moves. All moves should be valid (so for example dont try to move the hole up when it is in the first
row).
Scoring
Your program will receive n^3/(m+1) points for each test case where m is the number of moves.
Example
Input:
2
4
1
5
9
2 7
6 0
10 11
3
4
8
13 14 15
12
3
0 1 2
4 5 3
7 8 6
Output:
URDDD
RRDD
Input
An integer t denoting the number of test cases (t<=10), followed by t test cases, each consisting of a
line with a single integer n - the number of points on the sphere (2<=n<=1000).
Output
For each test case, output n lines consisting of three floating point numbers, corresponding to the x y z
coordinates of successive points.
Scoring
The score of your program is the total of scores awarded for individual test cases.
For each test case you will receive n*d points, where d denotes the minimum distance between the
closest pair of points in the solution output by your program. If you place some of the points further
than 10 -5 from the surface of the sphere, your solution will be regarded as incorrect.
Example
For the sample input:
1
2
a program outputting:
0.0 0.0 1.0
0.0 1.0 0.0
will receive 2.828 points.
Input
The first line of input contains a single positive integer t<=25, the number of test cases. t test cases (of
successively increasing size) follow.
Each test case begins with an integer n (2<=n<=26) denoting the size of the board. Then, the snapshot
of the earlier situation is given, followed by a snapshot of the later situation. Each snapshot is a
sequence of n lines of n characters, corresponding to the squares of a chessboard oriented as in the
figure above. Character . - denotes an empty square, W - a square with a white pawn, B - a square
with a black pawn. Assume that it is blacks turn to move after the earlier position (though black
neednt have necessarily started the game as such).
Output
For each test case, output the number k of moves which could have led from the first to the second
position (output 0 if you dont know a solution, even though such a solution exists for certain). In the
next k lines, print the determined sequence of moves. Each move should be given in a seperate line,
using the format: old_column old_row new_column to describe the change of coordinates of
a pawn (assume board orientation as in the exemplary figures).
Scoring
The score of your program is the total of scores awarded for individual test cases. For each test case
for which you find a solution in k moves you will receive k points.
Example
For the sample input:
1
6
....W.
.WWW.W
B.B...
......
......
B..BBB
......
.BWW..
.....W
......
.....B
B..BB.
a program outputting:
5
A
F
C
E
F
3
2
3
1
6
B
F
D
D
F
Input
The first line of input contains a single integer t<=500, the number of test cases.
The first line of every test case contains five integers n c h s x s y , respectively denoting: n - the length
of one side of the city (measured in squares), c - the number of dynamite charges Johnny can use, h the number of minutes after which the rain falls, s x , s y - the x and y coordinates of the square
containing the fire-station from which Johnny starts, measured relative to the North-West corner of the
city (1<=s x , s y <=n<=50, 0<=c<=h<=5*n; there are about 10 test cases for all possible values of n).
Finally, the map of the city is given in the form of n lines of n characters each, each corresponding to
the state of a square at the start of the fire fighting (b - building, g - grassland, w - water, f fire).
Output
For the i-th test case output a line containing the text city i Y if you want to solve the test case or
city i N if you wish to leave it out.
If you chose to the solve the test case, in the next line output a sequence of exactly h characters N,
S, W, E, + or -, corresponding to Johnnys actions in successive minutes (moving North,
South, West and East on the map, dropping dynamite, not doing anything, respectively).
Score
The total score is the total number of rescued squares with buildings taken over all test cases.
Example
Input:
5
3 2 9 1 1
bgg
bbg
bbf
4 2 8 3 1
bbbb
bgwg
fwgg
gbbb
4 3 15 2 1
bbbb
bbbb
bbbb
fbbb
4 3 15 2 1
bbbf
bbbb
bbbb
fbbb
4 3 15 2 1
bbbf
bbbb
bbbb
fbbb
Output:
city 1 Y
S+E---N+city 2 Y
W+SSS+-city 3 Y
ESE+SW+S+-----city 4 Y
+EES+W+-------city 5 Y
+ES+-E+-------Score:
9
(The first test case is illustrated in the figure and Johnny can save one building. In testcases 2, 3, 4, 5
Johnny saves 4, 2, 2 and 0 buildings, respectively).
Bonus info: The three digit number after the decimal point of your score denotes the number of test
cases you have solved correctly, rescuing at least one building.
Warning: large Input/Output data, be careful with certain languages
Added by: Micha Maafiejski
Date:
2004-10-11
Time limit: 17s
Source limit:50000B
Languages: All
Resource: -
Input
The first line of input contains a single positive integer t <= 1000, the number of test cases.
Each tests case begins with the number of towers 3 <= n <= 100, the number of target tower 1 <= k <=
n, the number of disks m <= 100 and the maximum distance 1 <= d <= n - 1.
Then, the following m lines consists of pairs of numbers describing the initial situation, in the form:
the tower and disk on it. Assume according to the rules that on every tower smaller disks are on larger
disks.
Output
Process all test cases. The correct output for the i-th test case takes the following form:
i [the number of the test case (in input order)]
a b [a sequence of lines of this form, where a is the tower with the moved disk on top of it and b is the
target tower].
The test case is considered solved if after performing the sequence all disks are on the k-th tower. At
the end of the series of moves you should always write a line consisting of two zeros (0 0).
Scoring
The score awarded to your program is the sum of scores for individual test cases. For the i-th test case
you will receive T i / ( T i + A i ) points, where T i <= 20000 and A i is the number of moves in your
solution. If you dont want to solve a test case, you may output the line 0 0 without a list of moves,
for which you will not be awarded any points. Your program may not write more than 30000 kB to
output (this will result in SIGXFSZ).
Example
Input
5
3 3 3
1 1
1 2
1 3
3 1 3
1 1
1 2
1 3
4 4 4
1 1
1 2
1 3
1 4
4 4 4
1 1
1 2
2 4
4 3
4 4 4
1 1
4 2
4 3
4 4
Output
1
1 3
1 2
3 2
1 3
2 1
2 3
1 3
0 0
2
0 0
3
0 0
4
4 3
2 4
3 4
1 2
1 3
3 4
2 4
0 0
5
1 2
0 0
Score
Assuming: T = {7,6,15,7,1} the output will receive 2 points.
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with non-zero score...
Added by: Micha Maafiejski
Date:
2004-10-27
Time limit: 17s
Source limit:50000B
Languages: All
Resource: -
Input
The input starts with a line containing integer t <= 1000, the number of test cases. t test cases follow.
The first line of a test cases begins with integer k, denoting the number of different available cable
lengths, followed by k space separated integers p j corresponding to the allowed lengths of cables (1
<= k <= 100, 1 <= p j <= 100). The next line contains two integers n m, denoting the required number
of nodes and cables in the network, respectively (1 <= n <= 100, 1 <= m <= 1000). The next m lines
contain a pair of integers a j b j each, signifying that nodes a j and b j should be connected by a cable (1
<= a j ,b j <= n).
Output
A valid solution to the i-th test case consists of a line with the text city i Y, followed by n i lines
each containing two integers, the x- and y-coordinates of successive nodes in the solution (0 <= x,y <=
100).
It is guaranteed that for every test case there exists at least one possible solution. You can however
leave out a test case by outputting the line city i N instead of a valid solution.
Score
For each correctly solved test case you are awarded (m/sum) * ((p 1 +p 2 +...+p k )/k) points, where sum
is the total length of all cables used.
The score awarded to your program is the sum of scores for individual test cases.
Example
Input:
4
2 1 2
4 5
1 2
2 3
3 4
1 4
2 4
1 2
4 5
1 2
2 3
3 4
1 4
2 4
2 1 2
5 8
1 2
1 3
1 4
1 5
2 4
2 5
3 4
3 5
1 1
2 1
1 2
Output:
city 1 Y
0 0
0 1
1 1
1 0
city 2 Y
2 0
1 1
0 2
0 0
city 3 Y
0 1
0 2
1 1
1 2
0 0
city 4 N
Score:
score = 3.340003
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with non-zero score...
Added by: Micha Maafiejski
Date:
2004-11-14
Time limit: 17s
Source limit:50000B
Languages: All
Resource: -
Input
The input starts with a line containing a single integer t<=100, the number of test cases. t test cases
follow.
The first line of every test case consists of four integers n x y S, denoting the number of good children
who will receive a present from Santa, the x and y coordinates of Santas home base, and the amount
of space in the sack, respectively (1<=n<=10000, -10000<=x,y<=10000, 1<=S<=100000). n lines
follow, each consisting of three integers x i y i s i - the x and y coordinates of the i-th childs home, and
the amount of space taken up by this childs present when in Santas sack, respectively
(-10000<=x i ,y i <=10000, 1<=s i <=S).
Output
For each test case output a sequence of space separated integers, corresponding to successive actions
that should be taken by Santa:
-i (1<=i<=n) signifies that Santa should travel to his base and pack the present for the i-th child
into his sack (he needs to have sufficient room in his sack to do this).
i (1<=i<=n) signifies that Santa should travel to the i-th childs home and leave a present for
him/her.
0 signifies that Santa should travel back to his base and end his Christmas activity (and that you
want to proceed to the next test case).
Assume that Santa starts in his base and always travels between points by the shortest possible route
(along straight lines). All distances are measured using the Euclidean metric.
Score
The score awarded to your program is the total of all scores obtained for its individual test cases. The
score for a test case is calculated as I/P, where P stands for the distance covered by Santa in your
solution, while I is a test case specific constant (I= n*d+D*(s 1 +...+s n )/S; d is the mean distance
between two homes, while D is the mean distance between Santas base and a childs home for the
given test case).
No points are awarded for incompletely solved test cases (when not all the children receive presents).
Any other violation of transport rules results in Wrong Answer.
Example
Input:
1
3 0 0 3
1 0 1
1 0 2
1 0 3
Output:
-1 -2 1 2 -3 3 0
Score:
2/(1+1+1+1)= 0.5
Score
Your program will be judged as follows: if the program is not a quine (i.e. if it contains no relevant
characters or outputs text different than its own source code) it will be judged as a Wrong Answer.
Any other program will receive some number of penalty points depending on its size and quality as a
tree (the fewer points, the better). One penalty point is given for every line of code used. 10 penalty
points are given for a line without any relevant characters (how can you expect a broken tree to
grow?). For non-empty lines, the position of the leftmost and rightmost relevant characters in the
analyzed tree are compared with respect to corresponding positions in an ideal tree with the same
number of lines. The squared differences in position between these two pairs of characters are added to
the penalty score.
Technical note: a single newline character (ASCII 10) should be used to terminate all lines. ASCII
characters 32 (space) and 9 (tab) are treated as single spaces, all other characters are considered
relevant. Notice that the problem description doesnt penalise for left out or excessive spaces after the
last relevant character of a line (but doesnt allow any difference between the source code and output
text in this respect).
Example
C source code:
;
;
;;;
;
main(
) {;
;
; ;
/* */
;return
0
;;}
This code would be judged as Wrong Answer, since it isnt a valid quine. Were it a quine, it would
receive 16 penalty points (12 for 12 lines, 4=2 2 additional penalty points for a misplaced rightmost
relevant character in line 5).
Solutions to this problem may only be submitted in the following languages: C, C++, Pascal,
Java, C#, Python, Haskell, OCaml, Brainf**k, Intercal.
Added by: Adrian Kosowski
Date:
2004-12-16
Time limit: 17s
Source
30000B
limit:
All except: ADA ASM BASH CLPS LISP clisp LISP sbcl D FORT ICON JAR LUA
Languages:
NEM NICE PAS gpc PERL PHP PIKE PRLG RUBY SCM qobi ST WSPC
Resource: DASM Programming League 2004, problemset 4
270. Digits of Pi
Problem code: PIVAL
In this problem you have to find as many digits of PI as possible.
Output
Output must contain as many digits of PI as possible (not more than 1000000).
Score
The score awarded to your program will be the first position of the digit where the first difference
occured.
Example
Output:
3.1415926535897932384626433832795
276. Herdkeeper
Problem code: MFENCE
After the tragic end of the watermelon plantation, Johnny has switched to farming. More precisely, he
is now a Certified Livestock Supervisor (i.e. shepherd) tending herds of antelope. It is his task to
divide the animals into herds, and to build a fence around each herd, trying to keep the total length of
all fences as small as possible. Each herd must consist of at least 2 antelope, and the antelope may
stand arbitrarily close to the fence itself.
Input
t [the number of test cases <= 1000]
n [2 <= the number of antelope <= 100]
x 1 y 1 [coordinates of the antelope, between -1000 and 1000]
x2 y2
.....
xn yn
[next test cases]
Output
case i Y [N - if you want to skip the testcase]
c [the number of herds]
a s 1 s 2 ... s a [2 <= a - the number of antelope in the first herd, and the numbers of the antelope in this
herd in the order from the input sequence]
[next test cases]
Scoring
The score awarded to your program is the sum of scores for individual test cases. For the i-th test case
you will receive 1 / ( 1 + sum / conv) points, where sum is the sum of circumferences of all convex
hulls of herds in your solution, and the conv is the circumference of the convex hull of the set of all
antelope. If you dont want to solve the i-th test case, you may output the line case i N and nothing
else.
Example
Input:
6
2
0 0
5 0
3
4 0
-4 -5
2 3
5
20 10
10 10
40 50
-20 -40
-30 -20
4
2 4
2 -4
2 0
-5 -3
3
2 4
-4 -4
2 3
4
-1 -3
-1 5
3 -5
-1 5
Output:
case 1 Y
1
2 1 2
case 2 Y
1
3 1 2 3
case 3 Y
2
3 1 2 3
2 4 5
case 4 Y
2
2 1 4
2 2 3
case 5 Y
1
3 1 2 3
case 6 Y
1
4 1 2 3 4
Score:
3.079001
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with score > 0.5
Added by: Micha Maafiejski
Date:
2005-01-07
Time limit: 17s
Source limit:50000B
Languages: All except: C99 strict
Resource: -
Input
t [the number of test cases <= 1000]
n k [2 <= the number of different buildings <= 100, 1 <= the number of shelters <= n-1]
x 1 y 1 [-1000 <= coordinates <= 1000]
x2 y2
.....
xn yn
[next test cases]
Output
case i Y [N if you wish to skip this test case]
b 1 b 2 ... b k [numbers of buildings to put shelters in, in increasing input order]
[next test cases]
Scoring
The score awarded to your program is the sum of scores for individual test cases. For the i-th test case
you will receive diam / dist points, where diam is the distance between the furthest two buildings of
the city, while dist is the longest distance from a building to the nearest shelter in your solution. If you
dont want to solve the i-th test case, you may output the line case i N and nothing else.
Example
Input:
5
5 2
-3 -4
-4 3
2 -3
-2 -3
-5 5
5 4
2 0
-5 -4
1 -1
-1 0
5 -5
5 2
-3 0
5 -2
-1 -5
2 4
4 5
5 3
5 0
-1 -5
3 2
-5 1
-1 3
5 4
-1 2
1 1
5 4
0 5
-2 2
Output:
case 1 Y
3 4
case 2 Y
1 3 4 5
case 3 Y
4 5
case 4 Y
1 2 3
case 5 N
Score:
5.592004
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with Y answer.
Added by: Micha Maafiejski
Date:
2005-01-21
Time limit: 17s
Source limit:50000B
Languages: All
Resource: -
Output
The output of your program must contain a set of rules describing the behaviour of the Turing
Machine designed for playing music. Each rule must be of the form S1 C1 S2 C2 M, where S1 and
S2 are integers from the range 0..999, C1 and C2 belong to the 16 symbols of the alphabet, while M
describes the move direction of the head by the sound it makes (da, di or um).
Score
Your program will be tested multiple times for different pieces of music written on the tape. The score
of your program is equal to the total of non-negative scores, taken over all test cases.
For a test case with n notes (n/2 non-silent cells) your program will receive n-d points, where d
denotes the edit distance between the music played and the music required (i.e. the minimum total
number of notes that have to be inserted into or changed in both the pieces to obtain the same piece of
music).
Example
Consider the following set of rules output by a program:
000
000
000
000
001
dada
umda
shsh
didi
dada
000
000
000
001
002
dada
dada
shsh
didi
didi
da
da
da
di
di
Bonus info: There are no more than 100 tests. The score format is s.xxyy, where xx denotes the number
of tests for which your machine played the music perfectly, yy - the number of tests for which it
received a positive score.
While this machine halts, it loops. We just help it in its agony.
Added by: Adrian Kosowski
Date:
2005-01-26
Time limit: 17s
Source limit:50000B
Languages: All
Resource: DASM Programming League 2004, problemset 6
Input
Input begins with a single integer t (t=1000). t test cases follow.
Each test case starts with a line containing two integers n k, respectively denoting the number of words
the teacher has asked Johnny to write and the total number of carbon copies that Johnny creates,
including the original (1<=k<=n<=512). Each of the next n lines contains a word assigned by the
teacher - a string of between 4 and 12 characters a, b, c or d. All words given at input are
Bytelandian nouns in common use.
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. Then in the former case print a single line containing the text that should
be written by Johnny. Exactly n lines with a single integer on each should follow, the i-th representing
the position of the first letter of the i-th word (on the page on which this word eventually appears,
before applying the correction pen).
Scoring
The score awarded to your program is the sum of scores taken over all test cases you chose to solve.
For each test case, the score is the difference between the total number of characters of the words
provided by the teacher and the number of characters of the text eventually handwritten by Johnny.
Programs which receive a negative score for some test case will be considered incorrect.
Example
Input:
1
4 2
aaaa
aaaa
aaaa
bbaaa
Output:
case 1 Y
aaaabbaaaa
1
1
7
5
Score:
17 - 10 = 7
When given in to the teacher, the 2 pages of homework may look as follows:
aaaa__aaaa
aaaabbaaa_
Input
Input begins with a single integer t (t=200). t test cases follow.
Each test case starts with a line containing two integers m n, denoting the number of vertices of the
sheet of paper and the shape drawn on it, respectively (3<=m,n<=600). The next m lines contain two
integers a i b i each (-20000<=a i , b i <=20000), corresponding to the x and y coordinates of vertices
of the sheet of paper (given in clockwise order). The description of the shape drawn on the sheet
follows, given in the next n lines in a similar form.
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. In the former case, in the next line output a permutation of the numbers
1...n denoting the order in which Johnny is supposed to cut out the respective sides of the shape drawn
on the sheet (vertices are numbered from 1 to n in the input order, and side s connects vertices s and 1
+ s mod n).
Score
The score awarded to your program is the sum of scores taken over all test cases you chose to solve.
For each test case, the score awarded to your program is equal to the ratio of the perimeter of the sheet
of paper and the total length of the lines along which the paper is cut.
Example
Input:
3
4 4
0 0
0 2
2 2
2 0
0 1
1 2
2 1
1 0
4 3
0 0
0 3
3 3
3 0
1 1
1 2
2 2
4 3
0 0
0 3
3 3
3 0
1 1
1 2
2 2
Output:
case 1 Y
1 2 3 4
case 2 Y
1 2 3
case 3 Y
3 2 1
Score:
4.94
Input
Input starts with a single integer t, the number of test cases (t<=100). t test cases follow.
Each test case begins with a line containing two integers n m k l, denoting the number of cities, the
number of direct connections between cities, the cost of upkeep of a kilometer of track, and the cost of
upkeep of a single railway line intersection, respectively (3<=n<=m<=10000, 0<=k,l<=100000). Each
of the next n lines contains two integers x i y i , corresponding to the X and Y coordinates of the i-th
city, measured in kilometers, respectively (-40000<=x i ,y i <=40000). Then exactly m lines follow,
containing a pair of integers a i b i each, which denote that cities a i and b i , numbered in input order,
are connected by a direct railway track (1<=a i , b i <=n). No three cities are collinear and no three
tracks intersect at one point. All tracks are bidirectional.
Output
For the i-th test case output a line containing the text case i Y or case i N, specifying whether
you wish to solve the given case. Then in the former case, write exactly n-1 lines containing one
integer each -- the numbers of the railway connections that ought to be left open (numbered in input
order). It is guaranteed that for the input data some solution always exists.
Score
The score awarded to your program is the sum of scores received for the test cases you chose to solve.
For each such test case you will receive (s/c)-1 points, where s is the cost of maintenance of the
original configuration, while c is the cost of maintenance of only those railway lines which youve
selected.
Example
Input:
1
4 5 1 100
0 0
0 1
1 1
1 0
1 2
2 3
1 3
3 4
4 2
Output:
case 1 Y
3
2
5
Score:
(100+1+1+1+1.414+1.414) / (100+1+1.414+1.414) - 1 = 0.019
Input
Input begins with a line containing a single integer t (t=100). t test cases follow.
Each test case starts with a line with three integers describing a single game: n sr sb, denoting the
length of the side of the playing board, the number of points scored by the red player (Johnny) and the
number of points scored by the black player (Johnnys oponent), respectively (3<=n<=250, 0<=sb<
sr). The next ceil(n 2 /2) lines contain 2 integers x i y i each - the coordinates of the squares where
Johnny placed his crosses in successive moves (1<= x i , y i <= n).
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. Then in the former case print exactly floor(n 2 /2) lines containining 2
integers each - the coordinates of the squares where Johnnys anonymous oponent placed his crosses
in successive moves.
Scoring
The score awarded to your program is equal to the number of correctly solved test cases. For each
case, the game defined by yours and Johnnys description must have the outcome (final score) defined
at input.
Example
Input:
1
3 2 1
1 1
2 3
2 2
3 3
1 2
Output:
case 1 Y
3 1
1 3
2 1
3 2
Score:
1
314. Digits of e
Problem code: EVAL
In this problem you have to find as many digits of E as possible.
Input
There is no input for this problem
Output
Output must contain as many digits of E as possible (max = 1000000)
Score
The score awarded to your program will be the first position of digit where first difference occured.
Example
Output:
2.7182
Input
The first line of input contains a single integer t, the number of test cases (t=1000). t test cases follow.
Each test cases starts with a line containing two integers n k, denoting the number of students and the
number of divisions to be formed, respectively (2<=2k<=n<=200). Each of the next n lines contains
two integers x i y i each (-1000 <= x i ,y i <= 1000), denoting the coordinates of the houses of successive
students.
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. Then in the former case print exactly k lines. Each line should start with
integer n j (n j >=2) and be followed by a space separated list of exactly n j increasing integers s jl ,
denoting the students belonging to the j-th division, numbered in input order (1<=s jl <=n). All
divisions must be disjoint and the sum of all numbers n j must equal n.
Score
The score awarded to your program is the total of scores for the test cases you chose to solve.
For each solved test case you will receive diam / (d*k) points, where diam denotes the distance
between the two furthest houses of members of the fellowship, and d is the distance between the two
furthest houses of members belonging to the same division.
Example
Input:
2
6 3
0 0
1 0
0 1
1 1
2 0
2 1
6 2
0 0
1 0
0 1
1 1
2 0
2 1
6 2
0 0
1 0
0 1
1 1
2 0
2 1
Output:
case 1 Y
3 1 2 4
3 3 5 6
case 2 Y
3 1 2 5
3 3 4 6
case 3 Y
2 1 3
4 2 4 5 6
Score:
1.849003
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with Y answer.
Added by: Micha Maafiejski
Date:
2005-03-11
Time limit: 17s
Source limit:50000B
Languages: All
Resource: -
[IMAGE]
Input
The first line of input contains a single positive integer t<=300 - the number of test cases. Then for
every test case first line specifies integer numbers R and C (number of rows and columns) of the
picture (1<=R<=50, 1<=C<=100). Below R lines are follow. Each line consists of any integers for
horizontal hints. The very last number for every line is 0. Then C lines are follow. Each line consists of
any integers for vertical hints. And again every line ends with 0.
Output
For every test case you should write decoded picture in the form of rectangle with R rows and C
characters in each line. Symbol #(sharp) means filled block and symbol .(point) means empty cell.
Score
The score awarded to your program is the total of all scores obtained for its individual test cases. The
score for a test case is calculated so that for each right row or column you get 1 points. The
row(column) is counted as a right if there is a group of filled cells for every number in beginning of
the row(or column) and lenght of every cell is equal corresponded number. If All rows and columns
are right your score multiply by 1.5 for this test case.
Example
Input:
1
10 5
3 0
2 2 0
5 0
5 0
3 0
1 0
1 0
3 0
2
3
3
5
1
5
3
0
0
0
0
8 0
3 0
1 1 0
Output:
.###.
##.##
#####
#####
.###.
..#..
..#..
..###
..##.
..###
Score:
(10+5)*1.5 = 22.500
Bonus info: If score = xxx.xxxaaa, aaa means the number of entirely correct test cases
Input
t - number of test cases, than t test cases follows. [t <= 100]
[empty line]
Eache test case starts with integer N equals to number of pictures in this test, than N pictures follows.
[4 <= N <= 10]
[empty line]
Description of each picture starts from two integers H and W - height and width of picture
accordingly. [5 <= H, W <= 50]
than follows exactly H lines each consists of W chars.
Description of picture consists of two simbols only: x - painted square and . - empty square. You
can be assured, that no other symbols are present at the description of a picture.
Output
For each test it is necessary to deduce on a separate line a string of chars with length equals to N. The
string should consist of a set of two chars x and 0. Where x corresponds to a dagger on a picture,
and 0 corresponds to a zero. If answer will contains other chars or length of a string wont equals to
N you will receive status "Wrong Answer".
Score
The score awarded to your program is the sum of scores for individual test cases. The score for
individual correctly solved test equals to N (Number of pictures in this test).
Example
Input:
1
5
5 5
x...x
.x.x.
..x..
.x.x.
x...x
5 5
xxxxx
x...x
x...x
x...x
xxxxx
6 6
..x...
..x...
xxxxxx
..x...
..x...
......
5 5
.xxx.
x...x
x...x
x...x
.xxx.
5 5
.xxx.
.x.x.
.xxx.
.....
.....
Output:
x0x00
Output:
You will recieve 5 points for this solution
Added by: Roman Sol
Date:
2005-02-09
Time limit: 21s
Source limit:50000B
Languages: All
Resource: ZCon 2005
321. X-Words
Problem code: XWORDS
It is quite simple really: Ill give you a list of words and you use them to make a crossword puzzle in a
16x32 grid. Youll be able to use the words more than once in the grid and there is a special "flipper"
square you can use as a wild card. The winner will be the program that can create the "best" fully
connected crossword in one minute. The original problem appeared here: Programmer of the month
contest (Feb. 2005).
The Starting Grid
- The grid will consist of 32 columns and 16 rows
The Word List
- There will be at least one word and fewer than 512 words in the wordlist
- Each word will be two letters long or more (WORDLENGTH >= 2)
- Each word will be sixteen letters long or less (WORDLENGTH <= 16)
- Words in the wordlist will contain only letters "A" through "Z" in upper case letters with no white
space
- Words will appear in the wordlist with one word per line
- Words will not be repeated in the wordlist, but they may be used multiple times in your solution
- Do not assume anything (like sorting) about arrangement of the words in the list
- Do not assume anything about whether a "word" is contained in any dictionary: POTM, ABCDEFG,
and XYZZY are all possible "words"
- Words in the list may be subsets of one another: SCAT, CAT, CATS and XCATS may all appear in
the same wordlist ... there is no bonus for using words containing other words ... see scoring note
below
- There may be words in the wordlist which are not possible to connect to any other words in the
wordlist
Placement of the Words onto the Grid
- Any word from the word list may be used in your solution as many times as you wish
- You may use any subset of words in the wordlist, or all of them
- All words placed on the grid must read left-to-right or downwards
- All words placed on the grid must be connected to one another
- ONLY words on the wordlist may be used and empty squares or grid boundaries must be used
immediately before and after all words
- Words may not "wrap-around" the grid boundaries in any sense
- Your solution does not need to be symmetric in any sense
- Output which is not connected, or contains words which do not appear in the wordlist, will receive a
score of zero
The Flipper Square
- There is one (and only one) "flipper" square (denoted by an asterisk) permitted in your output
- You may place the flipper square within any word you place on the grid
- When used, it may represent a different letter in the horizontal and vertical words of which it is a part
- Any words formed using the "flipper" square must be part of the wordlist (if C*T is placed on the
grid, then there must be a three letter word in the wordlist that begins with "C" and ends in "T")
- The "flipper" will likely be used at a word intersection, although this is not required (why would you
use it elsewhere??)
Input
t - number of test cases [t <= 10]
N - number of words for given test case, then N lines follows each line contain one word, in upper
case. Word will contain no whitespace or characters other than [A-Z].
Output
For each testcase your output must contain exactly 16 lines with 32 characters followed by a line feed
as in printf("\n") on each line. The letters in your output must be upper case [A-Z} as in the wordlist.
The "Flipper" (if used) in your output should be an asterisk "*". Squares that do not contain a letter or
a flipper should contain an underbar "_". There should be no white space in your output. Your output
must be exactly t*528 bytes.
Score
Your "SCORE" will be the total number of letters in all the words used in your solution. If a word is
contained within a longer word, only the longer word will contribute to the score ... for example, using
POTM would not score for the word POT even if both are in the wordlist. The "flipper" square
contributes to the word length as though it was a part of each word. The total score will be the sum of
scores for individual test cases.
Example
Input:
1
28
NECESSARY
POLITICAL
CONNECTED
SEPARATE
OPINIONS
REQUIRES
SEPARATION
SELFEVIDENT
UNALIENABLE
HAPPINESS
GOVERNMENTS
INSTITUTED
DERIVING
GOVERNMENT
DESTRUCTIVE
INSTITUTE
FOUNDATION
PRINCIPLES
ORGANIZING
ESTABLISHED
TRANSIENT
ACCORDINGLY
EXPERIENCE
SUFFERABLE
THEMSELVES
ABOLISHING
ACCUSTOMED
USURPATIONS
Output:
CONNECTED__USURPATIONS_CONNECTED
O_E___R___R_U____R_P___O_E___R__
NECESSARY_E_FOUNDATION_NECESSARY
N_E___N___Q_F____N_N___N_E_U_N__
E_S_INSTITUTED_INSTITUTE_S_F_S__
C_S_N_I___I_R____I_O___C_S_F_I_E
TRANSIENT_R_A_GOVERNMENT_A_E_E_S
E_R_T_N_H_E_B____N_S_X_E_R_R_N_T
D_Y_I_THEMSELVES_T___P_D_Y_A_T_A
____T___M___E__E_____E_____B___B
HAPP*NESS______P____PRINCIPLES_L
____T___E_SEPARATION_I_____E___I
SUFFERABLE_____R_____E_________S
____D___V_SEPARATION_NECESSARY_H
________E______T_____C_________E
HAPPINESS_THEMSELVES_ESTABLISHED
Score:
341
Input
The first line of input contains a single integer t, the number of test cases (t=100). t test cases follow.
Each test case starts with a line containing integer n, denoting the number of players on the board
(2<=n<=500). Each of the next n lines contains a list of integers: first, d i the length of the i-th players
list, followed by the considered list of exactly d i other players (numbered in input order from the
range 1 to n).
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. Then in the former case print a description of the longest known game
scenario, followed by a description of the shortest known game scenario. Each scenario starts with an
integer t, the duration of the game measured in seconds (0<=t<=n-1). Each of the next t lines contains
a list of integers, representing the identifiers of players eliminated by respective players in the given
second (one integer for each player left alive and capable of hitting an enemy at the start of the second,
ordered according to the input identifiers of the shooting players).
Score
The score awarded to your program is the total of scores for the test cases you chose to solve.
For each solved test case you will receive t max / t min -1 points, where t max is the length of the first
presented scenario, while t min - the length of the second one.
Example
Input:
1
4
2 2 3
2 1 3
3 1 2 4
1 3
Output:
case 1 Y
2
3 3 4 3
2 1
1
2 1 4 3
Score:
2/1 - 1 = 1.00
353. Displace
Problem code: DISPLACE
You are given two strings S1, S2 of not more than 250 characters each. S1 does not contain characters
( and ). You can swap two consecutive characters in S1. Your task is to do it in as small a number
of swapping operations as possible to obtain a string which contains S2 as a substring (you can assume
that for the given input, this can always be done).
Input
The first line of the input file contains an integer t representing the number of test cases (t < 20). Then
t test cases follow. Each test case has the following form:
The first line contains S1
The second line contains S2
Output
For each test case, output 0 iff you do not want to solve this test case. Otherwise, output a line
containing the number 1 and two more lines of the following form:
The first line contains an integer k representing the number of swap operations
The second line contains k integers p1 p2,..., pk separated by single spaces, pi means that in the
i-th operation, you swapped the i-th character and the (i+1)-th character in S1.
Score
Your task is to minimise your score for this problem. If you choose to solve a test case and the number
of swap of operations is smaller than 5000, your score is equal to the number of operations. Otherwise,
your score is 5000. Your total score is equal to the sum of scores for individual tests.
Example
Input:
1
ABCDEFGH
FC
Output:
1
3
5 4 3
Score:
3
Input
The first line of input contains integer t, the number of test cases (t<=100). t test cases follow.
The first line of each test case contains three integers n m k, denoting the number of clearings (each
with a mammoth on it), the number of alleys in the park, and the number of mammoths to tie each
mammoth to, respectively (1<=k<=n<=m<=2000).
Each of the next m lines contains a pair of integers a i b i , denoting that clearings a i and b i are
connected by an alley (1<=a i ,b i <=n).
Output
For the i-th test case output a line containing the text case i YES if you know a solution to the
given problem and case i NO in the opposite case. In the former case, you should then output
exactly (k*n)/2 lines, containing the description of a rope between two mammoths. Each such line
should begin with integer l, the length of the rope measured in alleys (l=1 or l=2) and be followed by
exactly l+1 integers corresponding to successive clearings on the path of the rope.
It is possible that for the given test case no answer exists; in that case the only allowed solutions is
case i NO.
Your score is equal to the number of test cases for which you gave the answer case i YES.
Example
Input:
3
4 4 2
1 2
2 3
3 1
1 4
4 4 1
1 2
2 3
3 1
1 4
3 3 2
1 2
2 3
3 1
Output:
case 1 NO
case 2 YES
1 2 3
1 1 4
case 3 NO
Score:
1+0+0 = 1
For the presented example, the optimal solution would score 2 points (for test cases 2 and 3).
Added by: Adrian Kosowski
Date:
2005-05-08
Time limit: 42s
Source limit:50000B
Languages: All except: C99 strict
Resource: DASM Programming League 2004, problemset 10
Input
case i [i-th test]
< list_eq >:=< eq >\n[< list_eq >]
< eq >:=< var >=(< onp >,< fraction >)
< onp >:=(_< var >,< onp >)(_< var >,< onp >)< op >
< var >:=(a,c,g,t)[< var >]
< op >:=(+,*,/)
< fraction >:=< number >/< number >
< number >:=(1-9)[< number >]
< id >:=
< id >
(x,y)
[x]
The definition of every variable (on the left side) appears only once and follows its last appearance on
the right side.
Output
The output should contain the list of variables in nondecreasing lexicographic order of identifiers and
all values should be represented as simple fractions in lowest terms, i.e. in the form N / D, where N and
D are relatively prime.
Score
The score is equal to the number of correctly solved test cases divided by 100.
Example
Input
case 1
c=_g_a/_cg_g/*
cg=_a_ct_a++
g=_a_a/_ct*
ct=_a_a*
a=2/2
case 2
t=_ct_ta*_ta*
ta=_c_a_a**
c=_ct_a+
ct=_a_a+_a_a*+
a=2/4
case 3
c=_t_cg_cg//
t=_g_g+_cg_g**
cg=_g_ct/
ct=_g_g/
g=6/71
case 4
g=_tt_tt_gt+*
t=_gt_tt*_tt/
gt=_tt_tt+_a_a*/
a=_tt_tt_tt/*
tt=2/62
case 5
c=_cc_t*
ca=_a_a/_a/
a=_cc_cc_t*+
cc=_t_t_t/*
t=76/13
Output
case 1 Y [write Y and the correct answer, write N if you dont wish to answer]
a 1 1
c 3 1
cg 3 1
ct 1 1
g 1 1
case 2 Y
a 1 2
c 7 4
ct 5 4
t 245 1024
ta 7 16
case 3 Y
c 432 357911
cg 6 71
ct 1 1
g 6 71
t 432 357911
case 4 Y
a 1 31
g 1923 961
gt 62 1
t 62 1
tt 1 31
case 5 Y
a 6764 169
c 5776 169
ca 169 6764
cc 76 13
t 76 13
Score
0.05
Output
For the i-th test case output a line with the text case i Y or case i N, specifying whether you
wish to solve the given case. Then in the former case print a single line containing the shortest
superstring. Exactly n lines with a single integer on each should follow, the i-th representing the
position of the first letter of the i-th word.
Scoring
The score awarded to your program is the sum of scores taken over all test cases you chose to solve.
For each test case, the score is the fraction of the total number of characters of the words and the
number of characters of the text. Programs which receive a negative score for some test case will be
considered incorrect.
Example
Input:
1
4
aaaa
aaaa
aaaa
bbaaa
Output:
case 1 Y
aaaabbaaaa
1
1
7
5
Score:
17/10 = 1.7
Bonus info: If score = xxx.xxxaaa, aaa means the number of test cases with Y answer.
Input
t - number of test cases, then t tests follow. [t <= 500]
In the first line of each test there is an integer N, and in the second line an integer K. N is the length of
the side of the square [2 <= N <= 1000], and K is the number of available rectangles [1 <= K <=
10000]. Then exactly K lines follow, with 3 numbers on each of them: wi, hi, li. wi - length of
rectangle [wi <= N], hi - height of rectangle [hi <= N], li - number of rectangles of this type [li <=
200000]. You may rotate a rectangle by a multiple of 90 degrees.
Output
For each test case output integer R - number of used rectangles, and then exactly R lines. On each of
these lines output integer coordinates of opposite corners of rectangle xi1, yi1, xi2, yi2. Solution will
be accepted if all rectangles wont intersect with each other and wont overrun the bounds of square.
Score
The score awarded to your program is the sum of scores for individual test cases. For individual test
case you will receive points equals to area cover with rectangles divided by area of square. For test in
which square doesnt have empty area, you will receive 4 points. If score = xxx.xxxaaa, aaa means the
number of test cases with fully covered square.
Example
Input :
1
10
8
3 5
2 2
2 3
2 5
4 5
1 3
3 8
1 1
2
1
1
1
1
2
1
1
Output :
9
1
6
9
1
6
9
1
2
3
1
1
1
4
6
3
8
8
8
5 3
8 5
10 2
5 7
10 7
10 5
1 10
2 10
10 10
Example explanation :
Fig.1
On the figure rectangles marked with numbers in accordance with position in example output.
For this test case you will receive 4.000001 points, because square fully covered with rectangles.
Added by: Roman Sol
Date:
2005-03-09
Time limit: 23s
Source limit:50000B
Languages: All
Resource: ZCon 2006
758. Tetris AI
Problem code: TTR
In the very heart of a well known producer of microelectronic products, a mobile phone with a built in
game of Network Tetris is being prepared for release. The owners of such mobile phones can arrange
duels when at a small distance from each other. Data transmission between players is carried out using
the Bluetooth protocol.
However -- now we are coming to the point -- it sometimes happens that there may be no other similar
phone nearby and the player may need to play alone. For this purpose it is necessary to write a
computer player (AI) with a very hard difficulty level.
The rules of Network Tetris are pretty simple :
The game has two playing fields, each with the rules of standard Tetris: figures of 4 blocks keep
falling from the top of the field, and have to placed in such a way as to form horizontal lines. Once a
line is filled up, it is removed and all lines above it are appropriately shifted downwards. There is
however one difference with respect to standard Tetris -- a player receives additional penalty lines as
soon as his opponent clears a line. The game is over when one of players fills his own field, either on
his own or with his opponents help, to such an extent, that the next figure cannot fully enter the field.
The width of the field is 10, and the height of field is 20. There are 6 types of figures in the game:
I (1) - [IMAGE]
L (2) - [IMAGE]
J (3) - [IMAGE]
Z (4) - [IMAGE]
S (5) - [IMAGE]
O (6) - [IMAGE]
[IMAGE]
It is your task to write a bot which starts with an empty field and, knowing the sequence of figures
dropping on its field, plays in such a way as to do as much harm as possible to the opponent.
Input
t - number of test cases [t <= 150], then t tests follow.
Each test case starts with integer N equal to the number of figures which drop onto the field [10 <= N
<= 50000]. Then N integers follow, numbered from 1 to 6 - denoting one of the figures, in the same
position as they appear in the pictures. (Look at numbers in parenthesis).
Output
For each test you should output line case 1 Y if you wish to solve this test case or case 1 N otherwise.
If you output Y, then exactly N lines must follow. Each of them should contain exactly two integers: A
and X, where A is the clockwise angle of rotation in the given move, numbered from 0 to 3 (0 - 0
degrees, 1 - 90 degrees, 2 - 180 degrees, 3 - 270 degrees), while X is the horizontal coordinate of
leftmost cube of the figure [1 <= x <= 10]. The i-th figure at input corresponds to the i-th figure at
output. If the figure falls outside the field or the parameters have incorrect value, or any falling figure
stops with at least one cube in a line of number larger than 20, then the solution will be judged as
Wrong Answer.
Score
The score will be equal to the total number of cleared lines, taken over all test cases. For one cleared
line your solution will receive 1 point, for two simultaneously cleared lines - 5 points, for three
simultaneously cleared lines - 15 points, for four simultaneously cleared lines - 30 points.
Example
Input :
1
14
3
2
4
5
3
2
1
6
6
1
1
4
1
5
Output :
case 1 Y
0 1
0 8
0 1
0 8
1 7
3 3
1 5
0 7
0 9
0 1
1 6
1 6
0 1
1 4
Score :
score = 30 + 1 = 31
761. Minesweeper
Problem code: MSWP
The puzzle "Minesweeper" is based on the widely known game "Minesweeper", available for almost
all MS Windows users, starting from version 2.0. The goal is simple -- to discover (or more precisely:
uncover) the positions of all mines in rectangular grid. After a field without a mine on it is uncovered,
the revealed value shows how many neighboring cells (at most 8) are occupied by mines. In the
puzzle, just as in the game, you know the total number of mines on the board. But unlike in the game,
you are not asked to risk your life by uncovering fields. Instead, you are given a list of uncovered
fields (without mines, with numbers on them) and are requested to hazard a guess at the locations of
all the mines.
Minesweeper
Input
t - the number of test cases, and then t tests follow [t <= 500].
Each test starts with three integers H, W, N equal to the height, width and number of mines on the
grid, respectively [5 <= H, W <= 50] [1 <= N <= H*W]
Then exactly H lines follow, each of them consisting of W symbols.
The description of the grid consists of ASCII characters: 1-8 - the number of mines in neighbouring
cells and . - a cell with unknown content. You can be sure that no other characters are present in the
grid description.
Output
For each test you should output the text char Y in a separate line if you wish to solve this test, or
char N otherwise. In the former case, you should then output a grid with the same size as that of the
test, with mines placed on it in stead of some characters .. Mines are defined by the character X.
The number of mines should be equal to the number of mines N given in the test description.
Score
The score of your program is the total of scores awarded for individual test cases. The score for a test
is equal to the number of cells around which mines are placed correctly (i.e. the number of mines is
equal to the integer displayed in the cell). The number of cells for which mines are placed incorrectly
is subtracted from this sum. Negative test case scores are treated as zero scores. If a test case is solved
entirely correctly, the score is multiplied by 10.
Additional info: The score is given as xxx.aaa, where aaa is number of tests solved entirely correctly.
Example
Input:
2
8 8 19
........
2323..2.
..23...2
.3..33..
2.321...
....1.32
.3...3..
1...2..2
6 6 6
111.1.
1.2121
112.21
..112.
122111
1..1..
Output:
Y
X.X.....
2323X.2X
.X23XX.2
X3X.33.X
2.321X.X
.XX.1.32
.3...3X.
1X.X2XX2
Y
111X1.
1X2121
112X21
..112.
122111
1.X1XX
Score:
The first test is solved entirely correctly, for which 23*10 = 230 points are awarded. The score for the
second test case is equal to 10-15 = -5, treated as 0. The total score is thus 230.001.
Added by: Roman Sol
Date:
2006-01-01
Time limit: 30s
Source limit:50000B
Languages: All
Resource: ZCon 2006
Output
For each number you should write to output the digit "1" if the number is prime or the digit "0" if it is
not prime.
Score
The score of your program will be the index of the first number in the sequence after which you do not
have a correct answer. Because of some limitation you should not write more than 33 333 333
characters to output. If you reach this limit, your score will be adjusted in accordance to your runtime.
Example
Output:
01000000000000000000000000001000010000000001100000
Input
t - the number of test cases; then t test cases follows. [t <= 500]
Each test case describes one SuDoku puzzle and consists of an 81-character-long string.
Output
For the i-th test case output a line containing Y if you want to solve the test case or N if you wish to
leave it out. If you chose to solve the test case, in the next line output a sequence of exactly 81
characters corresponding to the solution for the i-th Sudoku puzzle.
Score
The score for this task calculated using the formula: score = 200*total_solved/(200+time), where
total_solved - number of correctly solved puzzles, time - running time of your program. If the score
has the following form: xxx.xxxaaa, then aaa - is the number of correctly solved puzzles.
Example
Input:
3
..41..3.8.1....62...82..4.....3.28.9....7....7.16.8...562..17.3.3.....4.1....5...
1.......4....1.38.27.9.4...91.7...........5..86.4.5.9..3......8..9....2.4.......7
7..25..98..6....1....61.3..9....1.......8.4.9..75.28.1.94..3.......4923.61.....4.
Output:
Y
294167358315489627678253491456312879983574216721698534562941783839726145147835962
Y
198563274654217389273984615915726843347198562862435791731642958589371426426859137
N
Score:
In this case total_solved = 2. If the program runs for 10 seconds,
then the score of this solution will be equal to 1.905002
1416. Electrification
Problem code: ELC
We are trying to develop the electrical power infrastructure in the small country of Byteland. For this
purpose not far from each city we have built a nuclear power plant (NPP). We have also connected the
nearest house to this NPP with a cable. The goal of this project is to connect all houses of each city to
the source of electricity. Each house already connected to electricity become a source of electricity.
Since there is a severe shortage of electrical cable, the total length of the electricity network should be
kept as small as possible. In some places we can set up transformer/splitter boxes to which we can
potentially connect several cables; all their endpoints are then considered connected.
Input
t - the number of cities; then follows the description of each of t cities. [t <= 50]
The description of each city begins with N - the number of houses in the city [3 <= N <= 3000]. Then
exactly N lines follow, with two real numbers: x, y in each, representing the coordinates of a house.
[0.0 <= x, y <= 10000.0]
Output
For each test case you must output a connected electrical net, e.g. all houses must be connected with
each other, directly, through other houses or through transformers. For each test output integer M [0
<= M <= N] - the number of required transformers. On each of following M lines output the
coordinates of the transformers x, y [0.0 <= x, y <= 10000.0]. Next output the number K which is equal
to the number of required cables [N+M-1 <= K <= (M+N)*(M+N-1)/2]. On the following K lines
output two integers i, j - indexes of houses or transformers. Indexes for houses begins with 0 and end
with N-1, indexes for transformers begin with N and end with N+M-1.
Score
The score for the problem is given as: total_score = (200+time)*(score_1+score_2+...score_t)/200. In
the above formula, score_i is equal to the length of the electrical cable used for electrification of the
ith city, and time is the runtime of your solution.
Example
Input:
1
4
1.0 1.0
1.0 11.0
11.0 1.0
11.0 11.0
Output:
1
6.0 6.0
4
0
1
2
4
4
4
4
3
Score:
Suppose that the solution ran for 10 seconds. The length of the cable is score_1 = 20*sqrt(2). In this
case number of points awarded to the program will be equal to 29.698485.
Added by: Roman Sol
Date:
2006-04-12
Time limit: 45s
Source limit:60000B
Languages: All
Resource: ZCon 2007
Input
t - the number of test cases [t <= 60] (total number about 250), then t test cases follows.
Each test case begins with three integers: Q, H and W, denoting the noise probability for the generator
in percent, and the height and width of picture respectively [2 <= Q <= 20], [10 <= H, W <= 200].
Then H rows follow with W integers in each of them.
Output
For each test case you must output a picture after noise reduction in following format: In the first line
output the two integers H and W. Then H rows must follow with W integers in each of them. Each
integer is the color value of a pixel after the restoration process.
Score
The score of the program will be equal to the sum of scores for each single test case + 1. The number
of points for a single test case is calculated from the formula:
score = sqrt((x[1][1]1 - x[1][1]2)^2 + (x[1][2]1 - x[1][2]2)^2 + .... + (x[H][W]1-x[H][W]2)^2),
where x[i][j]1 is the color of the pixel at position i, j in the restored picture
and x[i][j]2 is the color of the pixel at position i, j in the original picture.
Example
Input:
1
6 20 20
255 255
255 255
255 000
255 000
255 000
255 058
255 076
255 000
255 000
255 255
036 255
255 255
255 255
255 255
255 255
255 255
022 022
255 255
255 255
255 255
255
200
255
255
255
058
255
255
255
255
255
100
255
255
255
177
022
255
255
255
255
255
255
255
255
058
255
255
255
255
255
195
255
255
255
255
022
255
079
255
255
255
096
096
096
096
096
096
096
255
255
002
002
002
002
255
066
255
079
255
255
255
255
255
255
255
255
255
255
255
255
167
002
002
002
255
022
255
079
255
255
255
079
079
079
079
079
079
079
255
255
002
002
002
002
255
022
255
079
255
255
255
079
255
255
079
255
255
079
255
255
002
002
002
002
104
022
255
079
255
255
255
079
255
255
079
255
242
079
058
255
002
002
002
002
255
022
255
079
255
255
255
079
255
255
079
255
255
079
255
255
002
002
002
013
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
046
002
255
022
255
079
255
255
255
045
045
045
045
185
045
045
255
255
002
002
002
002
255
022
255
079
255
255
255
255
129
255
255
255
255
255
198
255
002
002
002
002
255
022
255
079
255
255
255
045
045
045
045
045
045
043
255
255
002
002
002
002
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
002
002
255
022
255
079
255
255
255
068
068
068
068
068
068
048
255
255
002
088
002
002
255
022
255
079
255
255
255
043
255
255
255
255
255
048
255
255
255
255
255
255
012
022
255
079
255
028
255
043
255
255
255
255
255
048
255
255
255
255
255
255
133
022
255
255
203
255
255
043
043
189
068
068
068
048
255
255
255
255
143
255
255
022
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
022
255
255
255
Output:
20 20
253 253
254 255
255 000
255 000
255 000
255 058
255 000
255 000
255 000
255 255
255 255
255 255
255 255
255 255
255 255
255 255
022 022
255 255
255 255
255 255
255
255
255
255
255
058
255
255
255
255
255
255
255
255
255
255
022
255
255
255
255
255
255
255
255
058
255
255
255
255
255
255
255
255
255
255
022
255
079
255
255
255
096
096
096
096
096
096
096
255
255
002
002
002
002
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
002
002
255
022
255
079
255
255
255
079
079
079
079
079
079
079
255
255
002
002
002
002
255
022
255
079
255
255
255
079
255
255
079
255
255
079
255
255
002
002
002
002
255
022
255
079
255
255
255
079
255
255
079
255
255
079
255
255
002
002
002
002
255
022
255
079
255
255
255
079
255
255
079
255
255
079
255
255
002
002
002
002
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
002
002
255
022
255
079
255
255
255
045
045
045
045
045
045
045
255
255
002
002
002
002
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
002
002
255
022
255
079
255
255
255
045
045
045
045
045
045
043
255
255
002
002
002
002
255
022
255
079
255
255
255
255
255
255
255
255
255
255
255
255
002
002
002
002
255
022
255
079
255
255
255
068
068
068
068
068
068
048
255
255
002
002
002
002
255
022
255
079
255
255
255
043
255
255
255
255
255
048
255
255
255
255
255
255
255
022
255
079
255
255
255
043
255
255
255
255
255
048
255
255
255
255
255
255
255
022
255
255
255
255
255
043
043
043
068
068
068
048
255
255
255
255
255
255
255
022
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
022
255
255
255
255
255
255
255
255
255
255
255
255
255
255
002
002
255
255
079
079
079
079
079
079
079
255
255
002
002
255
255
079
255
255
079
255
255
079
255
255
002
002
255
255
079
255
255
079
255
255
079
255
255
002
002
255
255
079
255
255
079
255
255
079
255
255
002
002
255
255
255
255
255
255
255
255
255
255
255
002
002
255
255
045
045
045
045
045
045
045
255
255
002
002
255
255
255
255
255
255
255
255
255
255
255
002
002
255
255
045
045
045
045
045
045
043
255
255
002
002
255
255
255
255
255
255
255
255
255
255
255
002
002
255
255
068
068
068
068
068
068
048
255
255
002
002
255
255
043
255
255
255
255
255
048
255
255
255
255
255
255
043
255
255
255
255
255
048
255
255
255
255
255
255
043
043
043
068
068
068
048
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
Score:
Original
20 20
255 255
255 255
255 000
255 000
255 000
255 058
255 000
255 000
255 000
255 255
255 255
255 255
255 255
picture:
255
255
255
255
255
058
255
255
255
255
255
255
255
255
255
255
255
255
058
255
255
255
255
255
255
255
255
255
096
096
096
096
096
096
096
255
255
002
002
255
255
255
022
255
255
255
255
255
255
022
255
255
255
255
255
255
022
255
255
255
255
255
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
002
002
255
022
255
079
255
255
255
255
022
255
079
255
255
255
255
022
255
255
255
255
255
255
022
255
255
255
255
255
255
022
255
255
255
score = sqrt(2^2 + 2^2 + 1^2) + 1 = 1 + 3 = 4 (three pixels differ in the top-left corner)
Original picture: [IMAGE] Noisy picture: [IMAGE]
Input
There is no input for this problem
Output
The output must contain as many digits of the square root of 2 as possible (max = 2000000)
Score
The score awarded to your program will be the first position of the digit where the first difference
occurs.
Example
Output:
1.41421356237309504
Input
First line contains 3 integers N, M, B -- number of computers, number of pairs of computers can be
connected and the maximum number of computers that a computer can connect with. (1 <= N <= 10 4 ,
1 <= M <= 10 5 , 1 <= B <= N)
Next M lines, line i-th contains a triple (u[i], v[i], c[i]) -- means if we want to connect computers u[i]
and v[i] we should purchase a wire, cost c[i] (1 <= u[i], v[i] <= N, 1 <= c[i] <= 20000). The wires are
bidirectional.
Output
The first line contains 2 numbers --- total cost of your tree and the maximum degree in all computers
of that tree. Next, print N-1 lines, corresponding to N-1 edges of the tree, each edge on one line, forms
u v.
Example
Input:
3 3 2
1 2 1
2 3 1
1 3 5
Output:
2 2
1 2
2 3
Input
The first line of input contains t, the number of tests.
Each test begins with a line with alphabet A, which consists of lowercase letters arbitrary chosen from
the Latin alphabet. The next line contains an integer n<100 000 - the number of words. The subsequent
n contain one word each, which is not longer than 1 000 letters. Additionally, you can assume that the
total number of letters in all words of each test does not exceed 4*10 6 .
There is an empty line after each test.
Output
For each test output the sorted list of words in successive lines.
Score
The score is equal to the length of the source code of your program.
Example
Input:
2
re
3
ere
rer
re
balujemy
5
bel
luba
lej
bal
leje
Output:
re
rer
ere
bal
bel
luba
lej
leje
1558. Math II
Problem code: MATH2
Background
This is a mathematical(?) problem. See problem MATH1 and AMATH.
Input
The first line of the input contains a single integer c(1<=c<=2).
The second line contains 3 integer numbers separated by single spaces, D(1<=D<=1 000 000
000),n(1<=n<=700),m(1<=m<=700).
n lines follow, each contains m space-separated integer numbers.The number which is in the i-th row
and j-th column is defined as a(i,j).
Output
You should output n lines, each contains m integers,which is either 0 or 1.We define the number in the
i-th row and j-th column of your output b(i,j).
Score
If your answer is valid, the score of your program equals to the sum of the scores of each test case
multiply 10000.
The score for each test case is calculated in the following way:
a) c=1
The score S equals to
[IMAGE]
If S>1.5, your score will be multiplied by 10000.
b) c=2
The score S equals to
[IMAGE]
If S>2, your score will be multiplied by 10000.
Example
Input
1
7 3 4
1 6 4
7 0 3
2 5 1
#1:
6
3
5
Output #1:
0 1 0 1
1 0 1 0
0 1 0 1
Input
2
7 3 4
1 6 4
7 0 3
2 5 1
#2:
6
3
5
Output #2:
0 1 0 1
1 0 1 0
0 1 0 1
Score:
11428.5714
1690. Intercept
Problem code: INTER
Long long ago, so long ago, no body knows how long ago, there was a huge galactic war. There was a
very powerful general, General Ramuk, who had every possible soldier and scientist under him. One
of his scientists reports that he had intercepted a transmission that he believes is from the aliens. A
group of experienced cryptographers believe that in the following hypotheses:
1.
2.
3.
4.
5.
6.
The first transmission was completed. Ramuk is eagerly waiting for the second transmission, which
must be replied. Being such a simple problem, he asks you to write a program to do the same.
He says: "Nee evalovu chinnadha codea ezhudhariyo avalovu parisu onnakku kaathhirriku ", which
translates to: "The smaller the code you write, that much reward is awaiting you...".
You want to save the world from a probable Alien Invasion, and get as much money as possible.
Constant bit length numbers will be prefixed by 1s (0s in their notation).
Scoring
The scoring for this problem is the length of the source code.
Sample Input
NOTE: The colons (:) and newlines are for clarity
11111111111111111111110001001110:1111111111101111:0011100111000100
11111111111111111111110001001011:1111111111101100:0100100001000011111
Sample Output
0101101001
0010001111
Explanation
n1=945
n2=16
n3=50747
output=662
n1=948
n2=20
n3=376288
output=880
Tip: You may find this problem is like the problem GALAXY very much. To get round of the
programming problems of using Brainf**k, Whitespace or Intercal, you must use C/C++/Pascal/Java
to do the programming. Seems easy? Now there is an additional objective: there must not be any
semicolons ";" in your program!!!
Input
Multiple test cases, the number of them T is given in the very first line, T<=99. (In the judge data, T =
99.)
Each test case contains one line with a correct expression, without leading or trailing spaces.
Output
For each test case you should output one line contains the result of the expression without any leading
zeros. You may assume this number is always a non-negative one.
Example
Input:
3
6*7
67-25
31+11
Output:
42
42
42
Score
Thanks to Jin Bins suggestion, Ive changed this problem from a classical one to a challenge one.
Suppose the number of non-whitespace characters(ASCII 33 - 126) in your solution is K, the your
score is floor(K 3 /1000)+1.
Note
The judge had something wrong and it has been fixed on Jul.1, 2008. Please accept my apology.
Note 2
Sorry to some users, but the C function "system()" is prohibited in this problem. Judge has been
modified. Use problem CE to practice your programming skills without any(?) restrictions.
Added by: [Trichromatic] XilinX
Date:
2007-11-03
Time limit: 17s
Source limit:17000B
Languages: C C++ 4.0.0-8 JAVA PAS gpc PAS fpc
Resource: A copy of problem GALAXY, with language restrictions modified
As a mathematical
expression:
As a repeating
pattern:
B[0] = A[0] * C[0]
B[1] = A[0] * C[1]
+ A[1] * C[0]
B[2] = A[0] * C[2]
+ A[1] * C[1] +
A[2] * C[0]
B[3] = A[0] * C[3]
+ A[1] * C[2] +
A[2] * C[1] + A[3]
* C[0]
B[4] = A[0] * C[4]
+ A[1] * C[3] +
A[2] * C[2] + A[3]
* C[1] + A[4] *
C[0]
B[5] = A[0] * C[5]
+ A[1] * C[4] +
A[2] * C[3] + A[3]
* C[2] + A[4] *
C[1] + A[5] * C[0]
...
As a program:
for(int iB = 0; iB < len; iB++) {
for(int iC = 0; iC < len; iC++) {
B[iB + iC] += A[iB] * C[iC];
}
}
When you produce a solution (C), you can check your work by running the known algorithm on it, and
the output value (B) will be called Bprime. If B equals Bprime, then your program is working.
However, errors will be introduced into B, such that it is impossible to produce a matching Bprime. In
that case, your program must find the closest match. Here is the criteria for a success:
1. When given perfect inputs, B must match Bprime exactly.
2. The sum of the deltas between B and Bprime (sum(B[n] - Bprime[n])) must equal zero:
3. The sum of the differences between B and Bprime (sum(abs(B[n] - Bprime[n]))) must be as low
as possible:
Your score is the sum total of the errors between B and Bprime during its test. The goal is to get as
low a score as possible.
Notes:
1. The lengths of arrays A, B and C are the same.
2. The arrays are floating point numbers.
Input
Each request is sent in two lines; each of the values for A separated by spaces, and each of the values
for B separated by spaces. More than one request will be made.
Output
Your program must output the value for C on one line, separated by spaces, in response to each pair of
input lines.
Example
Input:
1 2 0 1 0 0
5 10 1 7 0 1
0 1 0 1 0 0 0
0 0 1 0 -1 0 0
0 1 0 1 0 0 0
0 0 0.5 0 1 0 0
Output:
5 0 1 0 0 0
0 0 0 0 0 0 0
0 0.75 0 0 0 0 0
All source code submitted for this problem must be free of intellectual property restrictions, and
becomes the intellectual property of Michael Mudge.
Input
t - the number of tests, then t tests follow. [t <= 500]
Each test starts with 3 integers: H - the number of rows of the playing field, W - the number of
columns of the playing field and C - the number of different colors of pieces. [4 <= H, W <= 50] and
[3 <= C <= 20]. Then follow H rows with W numbers in each, separated by spaces. Each number is in
the range from 0 to C-1 and describes the color of a piece.
Output
For each test you must output the letter "Y" if you want to solve this test, or the letter "N" otherwise. If
you output Y, you must output a set of lines with 2 integers x, y in each. These integers define rows
and columns in the field. [0 <= x < H], [0 <= y < W]. Coordinates are counted from the upper left
corner of field. After your last move output the line -1 -1. Youll receive status Wrong Answer if your
coordinates are outside the field, or point to an empty space, or to a single piece.
Score
The score received for this problem is calculated as follows: score = 200*total_score/(200+time),
where total_score - sum of points received for each playing field, time - process time for your solution
in seconds. The score for a playing field is calculated as (C*C*base_score)/(H*W), where S - number
of different colors, H - field height, W - field width, base_score - number of points calculated as in the
description of problem.
Example
Input:
1
4 4 3
0 0 1 1
1 1 2 2
0 1 2 0
0 1 1 2
Output:
Y
1 0
1 0
3 2
-1 -1
Explanation:
Initial field:
0
1
0
0
0
1
1
1
1
2
2
1
1
2
0
2
.
.
.
0
.
1
2
2
1
2
0
2
.
.
.
.
.
1
2
2
1
2
0
2
.
.
.
.
.
.
.
1
.
1
2
0
Score:
In this case base_score = 5*(5-1) + 4*(4-1) + 3*(3-1) = 20 + 12 + 6 = 38,
total_score = (3*3*38)/(4*4) = 21.375. Lets suppose that ittakes 10 seconds to finish calculations, then score = 200*21.375/210 = 20.357143
Input
There is no input data for this problem.
Output
You should output your solutions to every task one by one. If you dont want to solve some particular
task just output 0, otherwise output the length of your solution N. Then output exactly N lines
abc->def, where abc is the substring for replacement, and def is the substring by which it will be
replaced.
Score
For each correctly solved task you gain 1 point and additionally 1/N bonus points, where N is the
length of the proposed solution.
Example
Output:
0
0
0
5
a->b
b->c
d->v
g->l
l->a
0
0
Score:
In this case (if the set of rules leads to a correct answer)youll get 1 + 0.2 = 1.2 points for the 4-th task.
Input
t - the number of tests [t <= 500], then t tests follows. Each test consists of 200 rows with 200 chars in
each of them. Characters can be . and X, where . means the white color of the page, and X is the
black color of words.
The input data was generated using an on-line generator. The generator outputs data in 2 formats:
1) as a picture
2) as text
The datasets used for testing are such that all letters of the word are contained inside the picture.
Output
For each test output the recognized word in a separate line.
Score
The number of points youll receive for each image will be equal to the number of letters of the word,
provided that it is correctly recognized.
Example
Input:
2...........X...........X..............................................................X.................................................................................................................
.............................................X...........................X......................X.........................................X...............................................X.............
........................................................................................X...............................................................................................................
X............X....X...............................................................................................................X......X..................X......X.......................X..X.........
.........................................................X.........X.............................X.........................X.....XXX........X................................X..........................
................X.................................X...X....X......X.........................X...................................XXXXX.........................X.........................................
..............................X.X...........X.......................................................X......X....X.........X....XXXXXXX.........................................X........X...............
..............................................X...................................................................X..X.........XXXXXXXX.................................................................
......................................................................................................................X..........XXXXXXX................................................................
.....................................................................X............................................................XXXXXXX.......X......................X................................
...................................................X...........................X.....X...........X........X........................XXXXXXX...........................X..................................
.......................X...............................................................X............................................XXXXXXX.......................X...X.................................
.........X.................................................................................................X......X..................XXXXXXX.......................................................X....
.............X.........X.............................................X.....X...X.............X........................................XXXXXXXX...........................X...............X..............
...X....................................X.........................................................................................X....XXXXXXXX.........................................................
......................................X..........X...................................................................................X..XXXXXXXX.......................X................................
...........................................................................X.............................................................XXXXXXXX.......................................................
.....................................................X..X.........................................X.................XX...........X........XXXXXXXX......X.....................................X.........
......................X............................................................................................XXXXXXX.................XXXXXXXX....XX.................X.............................
....................X...........................................................................X..............X..XXXXXXXXXXXXX.............XXXXXXXX......X.....................X.......................
................................................................X................................................XXXXXXXXXXXXXXXXXXX.........XXXXXXXX...............X...................................
.............................................................................X......X..............X..............XXXXXXXXXXXXXXXXXXXXXXX.....XXXXXXXX..........X.......................X...............
......................X...........X.............X.............X....................................................XXXXXXXXXXXXXXXXXXXXXXXXXX..XXXXXXXX..............................................X..
....................................................................................................................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX....................................X...........
.X...................X.............................................................X.................................XXXXXXX...XXXXXXXXXXXXXXXXXXXXXXXXXX..X.........................................X..
................................X..................................................................................X..XXXXXXX.......XXXXXXXXXXXXXXXXXXXXXX...........X..................................
..................................X..............................................................................X.....XXXXXXX...........XXXXXXXXXXXXXXXXX...........................................X..
.......................................X................................................................................XXXXXXX..............XXXXXXXXXXXX...............................................
.....XX...........................................................................X......................................XXXXXXX..................XXXXXX................................................
..............................................................................................................X...........XXXXXXX..................................................X....................
................X.....................................X.......................................X............................XXXXXXX.X.........X.............X......................X..............X......
......................................................................................................X.....................XXXXXXX.................................X.............................X...X.
....................X..X..................................................X...........................X......................XXXXXXX...............X.....X............................X.................
..................................................X....X.......................................................X..............XXXXXXX...................................................................
...........................X.............................................................X.X...................................XXXXXXX..................................................................
........X.X.......X..........................................................................X......................X...........XXXXXXXX..............................X.................................
.X............................................................................X...................XXX............................XXXXXXXX.........................................X.....................
........X..................................X.....................................................XXXXX............................XXXXXXXX........................................X.................X...
................................................................................................XXXXXXX........X...................XXXXXXXX.............................................................
.................................X.......................X.......................................XXXXXXX............................XXXXXXXX..X....X...............X....................................
................................................................X.................................XXXXXXX............................XXXXXXX..............X.................................X...........
...................................................................................................XXXXXXX....................X.......XXXXX.....................X.......................................
......X........................................X....................................................XXXXXXX............................XXX..............................................................
................X....................................................................................XXXXXXX............X...............X.....................................................X.........
......................................X...................................................XXX...X.....XXXXXXX....................XX....................................................................X
......................................................X..................................XXXXX.........XXXXXXX..................XXXX.....................X..X...........................................
...................................X........................X...........................XXXXXXX.........XXXXXXX.XX..............XXXXX...................................................................
.........................................................................................XXXXXXX.X.......XXXXXXX...............XXXXXX....................X.............X................................
.................................................................................X.....X..XXXXXXX.........XXXXXXX.....X.......XXXXXXX................................................................X..
.......................................X...................................................XXXXXXX.........XXXXXXX...........XXXXXXX........X.............X............................X................
.....................................................X...X..................................XXXXXXX.........XXXXXXX.........XXXXXXX............................................X........................
...........................................X.....................X.........................X.XXXXXXX.X.......XXXXXXXX.X....XXXXXXX...........................................X..........................
..........X...........................................................X............X..........XXXXXXX.........XXXXXXX.....XXXXXXX.....X.............X............................X...X..................
.X.................................................................X..............XXX..........XXXXXXX.........XXXXXXXX..XXXXXXX..X.................X...................................................
...................................X.............................................XXXXX..........XXXXXXX........XXXXXXXXXXXXXXXX............................................X............................
................................................................................XXXXXXX..........XXXXXXX.........XXXXXXXXXXXXX.......X......................................X...........................
...................................X.....X......X................................XXXXXXX..........XXXXXXX.........XXXXXXXXXXX..............................................................X............
.......................................X..........................................XXXXXXX..........XXXXXXX......X..XXXXXXXXX...................X...........................X.......X....................
.......................................................................XX..........XXXXXXX...X..X...XXXXXXX..X......XXXXXXX.....................X................X.....................X................
.........................X........................X.................................XXXXXXX..........XXXXXXX.........XXXXX...................X..............................................X...........
................................X..X..X..............................................XXXXXXX..........XXXXXXX.X.......XXX......X.......................................................X................
.......................................................X..............................XXXXXXX..........XXXXXXXX........X...........................X....................................................
.................................................................X.....................XXXXXXXX.........XXXXXXXX.................................................................X......................
.......................X................................................................XXXXXXXX.........XXXXXXXX.............................................X.........................................
...................................X.X.................X..............X..................XXXXXXXX.........XXXXXXXX....X..X...........................................................X..................
..........................X....................X........X.................................XXXXXXXX.........XXXXXXXX.................................X..X.......X........................................
.X........................................X..........................XX........X...........XXXXXXXX.........XXXXXXX........................X................................................X...........
....................................................................XXXXXXX....X............XXXXXXXX.........XXXXX.....X........................X.......................................................
.....................................X................X...........XXXXXXXXXXXXXX.............XXXXXXXX.......X.XXX.......................................................................................
X........................X........................................XXXXXXXXXXXXXXXXXXX.........XXXXXXXX.........X......................................X.................................................
.................X.................................................XXXXXXXXXXXXXXXXXXXXXXX.....XXXXXXXX.............X........................................................................X..........
......X....................X...................................X....XXXXXXXXXXXXXXXXXXXXXXXXXX..XXXXXXXX...............................X........................................................X.X.....
.............................X...X...................................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX........................................X......................................................
.....................................X........................XX......XXXXXXX...XXXXXXXXXXXXXXXXXXXXXXXXXX..........................X...................................................................
.............................................................XXXX......XXXXXXX.......XXXXXXXXXXXXXXXXXXXXXX..........................................................................................X..
.....X..........................................X...........XXXXXX......XXXXXXX...........XXXXXXXXXXXXXXXXX...........XX...X............................................................................
................X...........................................XXXXXX.......XXXXXXX..............XXXXXXXXXXXX.....X........................................................................................
...........................................X.................XXXXXX.......XXXXXXX..................XXXXXX............................X.....................................X............................
.......X.................................X....................XXXXX........XXXXXXX...................................................X.............................X....................................
..............................................................XXXXXX........XXXXXXX..X..........X.........................X.....................................X...............X...............X.......
.............X............................................X....XXXXXX....X...XXXXXXX........X...........................................................X.........X...................X........X........
.....................................................X..........XXXXX.........XXXXXXX.................XX................................................................................................
..........X.....................................................XXXXXX.........XXXXXXX........................................................................X.........................................
...........................................X.....................XXXXXX.........XXXXXXX.................................................................................................................
.................................................................XXXXXX..........XXXXXXXX...................X..X........X...............................................................................
...............................X...........................X......XXXXXXX.......X.XXXXXXXX...........X................X..................X..................X...........................................
.........................X........................XX...............XXXXX...........XXXXXXXX................................X.................X.........X................................................
.................................................XXXXX.X...........XXXXXX...........XXXXXXXX...................................X........................................................................
X........................................XX..X..XXXXXXXX............XXXXXX...........XXXXXXXX.....................X.........................................................................X...........
...............................................XXXXXXXXXXX...........XXXXX.X..........XXXXXXX...................X..........X...............................................X............................
....X.........................................XXXXXXXXXXXXXX.........XXXXXX............XXXXX.....................................................X.....................X............X....X..............
......X.......................................XXXXXXXXXXXXXXX.........XXXXX.............XXX...........................X.................................................................................
........................X......................XXXXXXXXXXXXXXXX........XXXXX.............X...................................................................................................X.....X....
...............................................XXXXXX.XXXXXXXXXXX......XXXXXXX..................................................X.......................................................................
.........................X......................XXXXXX.XXXXXXXXXXXX.....XXXXX.....................X..............................X...........................X..........................................
................................X................XXXXX....XXXXXXXXXXX....XXXXX..........................X....................................X.......X...X.......................................X......
............X......................X.............XXXXXX.....XXXXXXXXXXX..XXXXX..................................................................................X....................................X..
........................X.........................XXXXXX......XXXXXXXXXXX.XXXXX...............X...........................................................................X.............................
..................X...........X...................XXXXXXX.......XXXXXXXXXXXXXXXX........................................................................................................................
..............................................X...XXXXXXX.........XXXXXXXXXXXXXX.........................................................X............................X.................................
...................................................XXXXXX...........XXXXXXXXXXXXX..................................X....................................................................................
...................................XXX..............XXXXXX............XXXXXXXXXXX.......................................................................................................................
..................................XXXXXX.............XXXXX..............XXXXXXXX........................................................................................................................
............X...X................XXXXXXXXX...........XXXXXX..............XXXXXXX.......................................X................................................................................
.....X...........................XXXXXXXXXX...........XXXXXX...............XXXX....................X...................X..............................................X..X..............................
...................................XXXXXXXXXX.......X.XXXXXX...........................................................X.........................................................X....................X.
.....................................XXXXXXXXXX........XXXXXXX....................................................................X...........................................X.........................
.......................................XXXXXXXXX.....X.XXXXXX.....................................................................................................................X.....................
..X.....................................XXXXXXXXXX......XXXXXX..........................................................................................................................................
...................................X....X.XXXXXXXXXX.....XXXXX................X.........................................................................................................................
...............................X......X.....XXXXXXXXX....XXXXXX.............XX..............................................................................................X...................X.......
..............................................XXXXXXXXX...XXXXXX.....................X..................................................................................................................
................................................XXXXXXXXX.XXXXXX...X............................X.................................X...........X..X......................................................
X......X.X........................X.X............XXXXXXXXX.XXXXXX.........................X................X.....X.....................................................X...................X............
...................................................XXXXXXXXXXXXXX....................................X.....................X............................................................................
.................................XX..................XXXXXXXXXXXXX...........................................X...X.X..........................................................................X.........
...........................X...........................XXXXXXXXXXX...X......................................X..................X........................................X...............................
...............................................X.........XXXXXXXXX.....................X................................................................................................................
..........................................................XXXXXXX..............................................................X.....................................X..................................
.............................X..........................X...XXXX...........X............................................................................................................................
....X..X..................................................X...X......................................X.....................X.....................................X......................................
....X....................................................X..............................X......X........................................................................................................
........................................................................................................................................................................................................
........................................X......X..X...............X...........................................................................X.......................X.............X...................
......................X......................................................X.....X...............X....................................................................................................
.........X.................................................................................................................X..........X..................................................X.............X
...........................X......................................................................................................................................X.....X...............................
......................................X...........................................................................X.......................................................X.........X.................X.
.............................................................................................................................................................................X....................X.....
....................................................................X................................X..................................................................................................
.................................................................................X.............................................X........................X......................X........................
........................X..................................................................................X...........................................................................X................
...........X.......................................X................X..............................X........................................................X.................................X.........
..........X.....................................................................................................X.......................................................................................
........................................................................................................................................................................................................
................................................................................................................X...............................................................X.......................
.............................X..............................................................X....................................................................X......................................
.....................X...............X....................X..................X....X.......X...............................................X......X......................................................
......................................................................................................................................................................X........................X........
..............................X.....X..................................................................................................................X..........X....................X..............X.
...........................X.X......................X.........X...............................X.......X..................................X................................X.............................
..X............................................................................X..........X......................................X....................................................X.................
.........................................................................................................................................................................X..........X..X................
.......................................................................................................................................X..........................X..........................X.........X
.....X.................................................X...........................X......X.................................................................................X...........................
............................X............................................................................X.X........................X...X.........................................................X.....
..X...........................................................X.......X...................................................X......................................................................X......
...........................X......................X....................X........................................................X.....X.................................................................
...................................X....................................................................................................................................................................
....................................................X.......................................................................................................X.......X.....................X.X...........
..........................XX.......................................................X...................X.......................................................................X........................
.................................X....................................................X.........................................................................X............................X.....X....
.................................................................X.......................................................X..............................................................................
............X...................X...................................................................................X..........................X........................................................
..............X.........................................................................................................................................................................................
........................................................................................X...............................................................................................................
..............................................................................X..................X.............................X........................................................................
.........................................................................X....X.............................X.....................X.....................................................................
..............................X............................................................X...................................X.................................................................X......
..........................................................................................................X.......X.....................................................................................
.............................................................................................X.....X....................................................................................................
..X............................................X...............................................................................X........................................................................
..................................................X...................X............................................X..X......................X...X..................X...................................
...........X.......................................X.X.......................................X................................................................................X................X........
................................................X..................................................................X...............................X.................................X..................
..X....................................................................X.................................................................................................................X..............
.....................................X..............................................................................................X...................................................................
......X........................................X..........................................................................................X.........................................................X...
..................................................X...................X..............................................................................................X........X.........................
.............X....................................................................X.......................X..................................................................X..........................
.............................X................................................................X....................................................X...............................X.......X............
.................................X..................................................................................X........................X.........X....................X...................X.......
.................................................................................................X.........................X............................................................................
...........X...X..............................................................................X.........................................................................................................
..................................................................................................................................X..................................................................X..
......X.........................................................................................................................X.......................................................................
.......................................................................................................................X................................X..............................................X
......................................................X..................................X...............................X..............................................................................
.............................X................................................................X.......................................................................XX.................X..............
.........................................X..........X.....................................................................................X.................X...X......................................X
......................................................X..........................................................................................................XX.....X...............................
.X..........................X...................X.....................................................X...................................................................X.............................
.............................................................X.................................................................................X..........................................X........X....
..........................................X............................................X................................................................................................................
......X..........X........................................................................................................X......X............................................................X.........
...................X...............X.............................................................................X........................................................X...X.........................
....................................X...........X..................................X....................................................................................................................
.............X........................................................X........X.......................................................X................................................................
..................X............................................X.........................................X............................................X................................................X
........................................................................................................X..X...........................................................................................X
.........................................X...................................................................................................................................................X..........
.......................X.......................................................................X....X...................................................................................................
...............................................................................................X.....................................X..................................................................
....X...........................................X...............................................................X.............X..............X..........................................................
....................................................X..............................................................................................X..X......................X....................X.....
............................................................................................X...............................X...............................X................X..........X...............
...X.............X...............X...........X.....................................................................................................................X....................................
.................................................................................................................................................X........................XX.X..........................
.X......X.............................X..............X.........................................................X................X.....X.................................................................
...X..............................................X.....................................................................................................................................................
..............X................................................................X....X...................................................................................................................
.........................X...............................................................X..X...........................................................................................................
.......................X................X..........X....................X.................................................X.....................X................X......................................
......................X...........................................................................................X.......................................X.........X...................................
...........X.........................................................................................................X...........X..........................X...........................................
................................X.............X...X.........................................X...............X........................................................X...............X..................
.................................................................X..............X.........X..............X..........................................X...................X............X..................
....................................................................................X................................................................X...................X..............................
..X...................................................................................................................................................................X.....X...........................
............................................................................X...........................X...............................................................................................
.........................................................................................................................X................................X.............................................
...................................................X.....................................................X......................X.......................................................................
...................................X...............................................X............X.......................................................................................................
....................................................X..........X..................................X......X....................................................X................................X........
............................X.......................................X..........................X.............................................X........................................X.........X.......
....................................................................................................................................................................................................X...
....................................X....................................................X.X...................X...X...............................................................X....................
...................X.......................................................................X............................................................................................................
..................................X............X.............................................................................X..........................................................................
............X..................X...........................................X...X..........X.............................X........X.......................X...........X.........X..............X.........
................................................................................................................X...............................X......X...X..............................X.............
......................................X...............................................................................................................X.X...................................X...........
X.............................................X..........X........................................................................................X................X....................................
.............................................................................X..........................................................................................................................
............................................................X..............................X......................................X.....................................................................
..........................................................................................................................X............................................X................................
...........................X..............................X...............................................................................X.............................................................
.............................................X....................................................................X.....................................................................................
......................................................................................................................................................X...X.............................................
...........................................................................................X.................................................................................................X.X........
..............................X.......................................................................X..X.............X..........X..............X......................................................
..........................................................X....................................X......................................................X.................................................
..............X....................................................................................................X.............X......................................................................
.............................................XX.....X.....................................X.............................................................................................................
........................X................................X.X.......................................................................................................................................X....
............X................X...............X............................................................................................X.............................................................
X.....X...............................................................................................X.................................................................................................
........................................X.............................................................X..............X.............................................X.................................X..
...................X...X..................................................X...................................X..............................................X...............................X..........
....................................X.............................X..................................................................X...........................................................X......
................................................X...............................X............X.................................................................................................X........
.......X..................................X.............................................................................................................................................................
.................X.............X....X............................................................................................................................X............X.........................
...........................................................X............................................................................................................................................
............................................................................................X...........X.......X.........................X..................................X.........................X
...X....................................................................................X..............X..X............................X................................................................
....................................................X...........................X............X...................................................................X.X....................................
....................................X..........X......X...........................................X..........X.........X.........X.................................................................X....
...............................................X...........X.X....................................................X...............X.....................................................................
...................................................................X....................................................................................................................................
...........................................................................................................................................................................X...X........................
...............................................X........................................X..............................................................................................X................
....................................X..............................X.........X.X........................................................................X...............................................
........................................................X....X........................................................................X....................................X.........................X..
....................X........................................................................X.............................................X..X...............X..X......................................
.........................X..................................X...............................X...X.............................................................X.........................................
...............X.......................X....................X......X....................................................................................X...........................................X...
............................................X...........X...............X..................X...........X....................................X...........................................................
...X.....................................................X..............................................................................................................................................
.....................................................X..................................X...................................................................................X...........................
........X.............................................................X................X.....................................X.......................................X..................................
X..................X......X...........................................................................................X...............X.................................................................
.........................................................................X.......................................................................................................X..............X.......
..............X..........................X...........................X..............................X...................................................................................................
..................................X.............X..................................................................................................X...................................................X
....................................X................................................................................................................................................X....X.............
.............X..........................................................................................................................................................................................
.................................X..................................................................................................................................................X.................X.
....................................................................................X...................................................................................................................
.............................................X........................................X.X..................................................................X...........................................X
.....................................X....................................................................................................................................X.X........X...............X..
................................X......X...............................X....................................................X..............................X............................................
.............X..........................................................................................................................................................................................
...........................................................X............X......................................................................................................................X........
...........................................................................................................................................................X............................................
......X........................................................................X.................X...................................................................................................X..
.....X..................................................................X...............................................................................................................................
.........................................................................................................................................................X..............................................
.............................X.....................................................X.........................................................X..........................................................
...........................X....................................................X.......X............................................X........X.......................................X.................
.........................................X.....................................................................X.......................X..................................................X.............
.X................................................................................................................................X.....................................................................
........................................................X...........................X.................X......................X..........................................................................
......X..........................................................X...............X....................X....................X...........X.X.....................X..X.....................................
XX..................................................................XXX.................................................................................................................................
....X.......X..................................X.....................XXX...........................X..............................................X.............................................X.......
...................X........X.................................X......XXXX...............................................................................................................................
....................................................................XXXXXXX....................................X....................................X....X...............X..............................
.....................................X.............................XXX..XXXX....X.........................X.............................................................................................
........X.........................................................XXX.....XXX.............................X.................................................X.....................X..X.............X....
.............X...............................X....................XX.......XX........................................................X..................................................................
.................................................................XXX........XX.........X.........................................................................................................X......
................X...............................................XXXX........XX..X........X...X................X.................X..............................X........................................
...............................................XX.............XXXX..........XX.................................................................................................X...........X............
.X..........................................X..................XXXX.........XX...XX..........................................X...................X......................................................
.X..........................X.................................XXXXXXX.......XX...XXXX.......................X............X....X.........................X...............................X........X......
.............................................................XXX..XXXX.....XXX....XXX.......................................................................................................X...........
............................................................XXX.....XXXXXXXXX....XXXX.................................................................X.................................................
.X...X...................................................XXXXX.....X.XXXXXXX....XXXXX...................X...............................................................................................
................................X........................XXXX..................XXXXX..........................X.......................X................................................X................
...........................................................XXX................XXX.XX.............................XX.....................................................................................
............................................................XXX...............XX..XX.....................X........X........X.....................X...........................X.......................X..
..................................................X..........XXX.............XXX..XX...........................................X..........................................................X..........X..
......................X.......................................XX............XXX...XX.........XX.........................................................................................................
.................................X.......................................X.XXX..XXX........XXXXX.....X...........................................................................X......................
..........X................................X....X.....X....................XX....XX.....XXXXXXXXX.......................................................................................................
.....................................................................X....XXX....XX...XXXXXXXX.XX......X..............X.................................................................................
...............................X.........................................XXX....XXX.XXXXX..XX.....XXX...........................................X.......................................................
....................X.................................................XXXXX......XXXXXX...XXX......XXXX.................................................................................................
.................................X..X.................................XXXX......XXXXX....XXX........XXX.............................................................X........................X..........
.............X.....X...........................................X.......XXX.......XX.....XXX..........XXXX..................................................X............................................
.........................XX...X................................X........XXX..X..........XX..........XXXXX..................................................X.........................................X..
..X..........XX.......................................................................XXXX.........XXX.XX................X..............................................................................
......................................................................................XXX........XXXX..XX...................................X...........................................................
.............................................XX......X.........X....X................XXX.......XXXX....XX...............................................................................................
..............................X.....................................................XXX.......XXXX....XX..................X.............................................................................
X...................X...............................................................XX......XXXX......XX................................................................................................
..........................X...................X.....X............................XXXXX.....XXXXXX.....XX...........................................X........X...........................................
..X.......................................................X......................XXXX....XXXXXXXX....XX.............X................................X..........................X.......................
....X................................................X.........X..................XXXXXXXXX....XXX...XXX................................................................................................
.....................X..............................X...............................XXXXXX......XXXX.XX................X...............................................X................................
.............X........................................X...............................XXX........XXXXX...................................................X..................................X...........
.............X.......................................X...........X.....................XXX.........XXX..................................................................................................
..................................................................X.X....................X..........XX..........................................................X...................................X...
....XX......X.......X.............................................X................X...............XX.................X.............X........X........................X...X....X........................
.....................................................X.............................................XX...................................................................................................
...................................................................................X.X.............XX................................................X........X.........................................
...........................X................................X.....................................XX.................................................X.........................................X........
............................X...................................................................XXXX.......................................................X......................................X.....
...........................................X....................................................XXXX.........................................................................X..........................
.X..................X..........................................................XX................XXXX............................................................X......................................
........................................................................................X..........XX......X...........................X............................................X...X...............
............................................X.................................X.............................................................................X............X.......X.............X........
X...............................................X..........X......................X...................................................................................................X.................
.................................................X...................X..........X.....X...............................................................X...........X.....................................
.....................................................................................................................................................X..................................................
....................................................................................................................................X..............................................X....................
....................................................................................................................X.........................................................X.......................X.
......X..........................................X...............XX.....................................................................................................................................
.............X..............X............................................................X..............................................................................................................
X............X...X................X...............................................................X.....................................................................................................
........................................................................................X................................................................................X.................X............
.......................X.................X.....................X...............................XX......................................................X..............................................X.
X.XX...........................................................X.....................X............................X..................................X..................................................
.............................................X.....................................................X..........................X........................................X................................
........................................................................X...........X......X............X........................................................................X......................
.........XX......X.................................................X...............................X...........X..X...........................................X..............X..........................
........................................................................................................................................................................................................
.................................................X.................X......................................................................X.............................................................
................................................................................................................................................................X.......................................
......................X.............................................................................................................X..........................................................X........
..X..X...X.......................................................X.....................X.........................................................................X...................X..................
........X.............................................X..............................................................................................................................X..................
.............................................................................................X..............................................................................X....................X......
..........................X.......X................................................X....................................................................................................................
....X..............X.....................X.......................X.................................................................X....................................................................
...........................................................................................................X.....................................................................X......................
........................................................................................................................................................................X.............X..X..............
..X........................................................................X...........................................X........X.X........X...........X................................................
...............X.................X.......X.............................................................................................................X................................................
.........X....X................................X...................................................................................................X.......................................X............
..X.............X.....................X.............................................................................X..X...........................X............................XX..X...................
.....X..........................X......................................................X.............................X..X...............X....X.......................X.............X....................
.......X...............XX.....................X.........................................................................................................................................................
...........................X..............................................................X...............................................X...................X.........................................
.............................................................................................................................................X..........................................................
....................................X...........................................................................X..............X........X.....X.X.......................................................
...............X...................................X.............................X...................................X...............................................................X..................
........................................................................................................................................................................................................
..................................................X.................................................................................................X...................................................
........................................................................................................................................................................................................
......................................X......................................................................................................................X..........................................
......................................X...........................................................................................................X.....................................................
......X................X.........................................................................................................................................................X......................
.X.............X......................................................X.............................................................X...................................................................
......X..........................................X......................................................................................................................................................
...........................................................................................................X...........................X....................X..........X....X...........................
..............................................................................................................................X.........................................................................
..............................................X..X......................................................................................................................X...............................
.......................X................................X...............................X...X........................................................X..................X...............................
.............................................................................................................X....................X...................X.............X..........................X....X...
........................................X.....................X.......................................................X........X......X....................X............................................
............................................................X........X..X....................X..........................................................X...........................X...................
........................................................................................................................................................................................................
.....X.......X.......X.......................................................X........X.........................................................X.....................................X.................
..................X.............................................................X...........................................................X..........X.......X........................................
..X..............................X.........................X..............................X.....................X.......................................................................................
.....................................................................................X.................................................................................................X................
....................................................X...................................................................................................................................................
...................................X................X..........X...............................................................X..................X...........X.....................X.......X...........
..............X................X..................................................................................X...........X...X.............................X....................X..................
...............X........................................................................................................................................................................................
....................................X................X..........................................................................................................X..............................X........
....................................................................................................................................................................X...................................
..........................................................................................X.............................................................................................................
........................................................X.......................X..........................X............................................................................................
............X......X.......X.........X.........................................................................X.....X........................................X.....................................XX..
..............................X.....................................................................................................................................X...................................
...X.........X...........................................X................XX............................................................................................................................
......................................................X..................................................................................................................................X..............
Output:
WNILN
PML
Score:
score = 5 (first test is correct and contains 5 letters, the second test has an error in the last letter)
Examples of images:
[IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE] [IMAGE]
Additional pictures can be generated with the on-line generator.
2659. Carl
Problem code: CARL
Professor Octastichs has invented a new programming language, Carl. An expression in Carl may be a
positive or negative integer, or may be of the form (p e1 e2) where p is a real number between 0 and 1
(inclusive) and e1 and e2 are Carl expressions. An integer represents itself and (p e1 e2) represents x +
y where x is the value of e1 and y is the value of e2 with probability p, otherwise it represents x - y.
Given a Carl expression, what is its expected value?
Input
Input consists of several Carl expressions, one per line, followed by a line containing ().
Output
For each expression, output its expected value to two decimal places.
Score
Score is the length of your source program.
Example
Input:
7
(.5 3 9)
()
Output:
7.00
3.00
Input
A line contains an integer n.
Output
The required string described above.
Score
Score is the length of your code.
Example
Input:
-2
Source:
abcdefg
Output:
gfedcbagfedcba
Score:
7
Hint:
You can contact me if you have any question about the Special Judge or your code.
Added by:
Date:
Time limit:
Source
limit:
Cluster:
Bin Jin
2008-10-03
1s
10240B
3880. Nop
Problem code: NOP
Mirko purchased a new microprocessor. Unfortunately, he soon learned that many of his programs that
he wrote for his old processor didnt work on the new processor.
Deep inside the technical documentation for both processors, he found an explanation. In order to
work faster, the new processor imposes certain constraints on the machine code of programs,
constraints that never existed on the previous model.
The machine code of a processor consists of instructions that are executed sequentially. Each
instruction uses a byte of memory. Also, instructions can have zero or more parameters, each of which
uses an additional byte of memory. In machine code, parameters immediately follow an instruction.
When formatted as text, machine code instructions are uppercase letters, while parameters are
lowercase letters. For example:
A b c b B c c C D e f g h
This program consists of four instructions; the first takes three parameters, the second two, the third
none and the fourth takes four parameters. The program uses 13 bytes of memory.
The new processor model fetches memory in four-byte chunks so each instruction must start at a
memory address that is divisible by four (the first byte in memory is address 0). To achieve that, we
can insert NOP (no operation) instructions into the old program, instructions that do nothing and are
not limited to memory locations divisible by four. The above program, adapted to run on the new
processor, can look like this:
A b c b B c c NOP C NOP NOP NOP D e f g h
The instructions A, B, C and D are now at memory locations 0, 4, 8 and 12, which satisfies the
processors constraints.
Write a program that determines the smallest number of NOP instructions that need to be inserted for
the given program to work on the new processor model.
Input
The input contains the machine code of the program written for the old processor model. The program
will consist of at most 200 English letters.
The program will always start in an instruction i.e. the first letter in the machine code will be
uppercase. If an instruction appears more than once in the machine code, it will always take the same
number of parameters.
Output
Output the smallest number of NOP instructions needed to adapt the program for the new processor.
Example
Input
Abcd
Output
0
Input
EaEbFabG
Output
5
Input
AbcbBccCDefgh
Output
4
Input
Nothing
Output
Just: "SPOJ is indeed awesome"
Example
Input:
Output:
SPOJ is indeed awesome
Input
Input consists of a single integer number 1<=N<=100, the size of the board.
Output
Output one possible placing of the numbers. You are to write N lines, N space separated integers each.
Example
Input:
3
Output:
1 2 3
4 5 6
7 8 9
Score:
Score for the example is:
Distance 1 -> 2 : 1
Distance 2 -> 3 : 1
Distance 3 -> 4 : 3
Distance 4 -> 5 : 1
Distance 5 -> 6 : 1
Distance 6 -> 7 : 3
Distance 7 -> 8 : 1
Distance 8 -> 9 : 1
Distance 9 -> 1 : 4
Sum of distances (SOD): 16, Min SOD: 10, Score: 1+16-10=7 points.
Input
The first line of the input contains a single integer N < 55, the number of problem instances to follow.
Each of the following N lines gives a separate dataset as a sequence of numbers separated by spaces.
The first number on each line gives the number M of pancakes in the data set. The remainder of the
data set is the numbers 1 through M in some order, each with a plus or minus sign, giving the initial
pancake stack. The numbers indicate the relative sizes of the pancakes and the signs indicate whether
the burned side is up (-) or down (+). M will be, at most, 1000.
Output
For each dataset, you should generate one line of output with the following values: The number of
flips (K, where 0 <= K <= 3000) required to sort the pancakes and a sequence of K numbers, each of
which gives the number of pancakes to flip on the corresponding sorting step. There may be several
correct solutions for some datasets and your task is to find the shortest one.
Score
For each test case is (3M-1)/(K+1)
Example
Input:
5
12 -2 -1 -10
11 +2 +6 -10
11 +1 +8 +11
13 -2 -12 +8
12 +11 -3 +7
+7 -4 -8 +12 -3 +5 +11 +6 -9
+4 -1 -5 +7 -8 -3 +9 -11
+10 +4 +3 -5 +2 -6 -7 -9
+9 +10 -6 -5 +3 -7 -4 +11 -1 +13
-5 -8 -12 -9 -1 +4 -2 -10 +6
Output:
25 7 12 3 1 11 4 10 2 1 9 3 1 8 6 7 2 1 6 4 5 1 1 4 1 3
25 11 1 11 3 1 10 1 1 9 7 1 8 2 1 6 1 5 3 4 2 1 3 1 2 1
25 3 11 8 1 10 3 9 7 1 8 7 1 7 6 1 6 4 1 5 3 4 1 1 3 1
24 2 1 12 2 1 11 4 10 3 7 2 1 6 4 5 2 1 4 1 3 1 1 2 1
29 6 1 12 7 11 6 10 1 1 9 5 1 8 6 7 5 6 2 5 2 1 4 1 1 3 1 1 2 1
Score:
6.4943590
Input
The first line contains T (1 <= T <= 1000) - the number of tests. The next T lines contain six integers
x1, y1, r1, x2, y2 and r2 (0 <= xi, yi, ri <= 10000) - coordinates and radii of the first and second
sprinkler, respectively.
Output
For each test case print the absolute value of the difference between the the area that is going to be
watered only in the moring and the area that is going to be watered only in the evening rounded to two
decimals after the point. Your score is the source length.
Example
Input:
1
2 2 4 5 2 3
Output:
21.99
6338. Monster
Problem code: MONS
Your Task is simple. Write the code that will print the content of the following file.
https://www.spoj.pl/content/skydbms:monster
Input
No Input
Output
The content of the above file.
Score
Minimum is the size, better is the score.
Added by: A@K@$h J0h@rI
Date:
2010-03-14
Time limit: 1s-5s
Source limit:3000B
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 JAVA
Resource: Own Problem
(42)
42
(1+(2*3))
1+(2*3)
(1+((61%(3+6))*7))
1+61%(3+6)*7
Example
Input
6
42
1+2*3
1%6*2
2/0
(1+((61%(3+6))*7))
(((((1)))))
Output
(42)
(1+(2*3))
((1%6)*2)
(2/0)
(1+((61%(3+6))*7))
(1)
Score
Your score is the length of your source code.
Added by: Jargon
Date:
2010-05-13
Time limit: 1s
Source limit:50000B
Languages: All except: PERL 6
Resource: Own problem
Input
The first lines of the input is an integer N (1 <= N <= 100). Next follows the input consisting of ASCII
characters. The input is terminated by EOF. You may assume that length of each word is less then
1024 and maximum number of words can be never more than 1024.
Output
The input reversed N times with atleast a space/newline between any two words of your output.
Input:
2
fox jumpsover thelazy dog.
Output:
.god .god yzal yzal eht eht revo revo spmuj spmuj xof xof
Input:
1
It matters not how strait the gate,
How charged with punishments the scroll.
I am the master of my fate:
I am the captain of my soul.
Output:
.luos ym fo niatpac eht ma I
:etaf ym fo retsam eht ma I
.llorcs eht stnemhsinup htiw degrahc woH
,etag eht tiarts woh ton srettam tI
.luos ym fo niatpac eht ma I
:etaf ym fo retsam eht ma I
.llorcs eht stnemhsinup htiw degrahc woH
,etag eht tiarts woh ton srettam tI
Input
First line of input has a single positive integer t = number of test cases. In the next t lines, given a
number in word form.
Output
Output the number as specified.
Example
Input:3one hundred twenty threethirty four thousand one hundred eightelevenOutput:1233410811Score : Source code length
Input
An integer N (0<N<7), one in each line. Input is terminated by EOF.
Output
The face of the die giving the appropiate value.
Example
Input:123456
Output:
0 0 00 1 00 0 00 0 10 0 01 0 01 0 00 1 00 0 11 0 10 0 01 0 11 0 10 1 01 0 11 0 11 0 11 0 1
Input
In this task you just need to convert a number from its digit form to word form. For example, you should output one for 1,thirty seven thousand for 37000 . You can assume that input will be >= 0 and < 50000. Also all numbers will be valid i.e input will not have numbers like 023.
Output
Example
12334108
Output:
Added by:
Date:
Time limit:
Source
limit:
Languages:
Resource:
Input:
8473. PATHS
Problem code: WAYS
Problem Statement:
Consider a square matrix of order m(m rows and m columns). At each step you can move one step to
the right or one step to the top. How many possibilities are to reach (m,m) from (0,0)?
Input:
The first line consists of an integer t, the number of testcases. Each testcase consists of a single
integer m, the order of square matrix.
Output:
For each case print the number of possibilities of reaching the point (m,m) from (0,0)
Input Constraints:
1<=t<=10
1<=m<=14
Example:
Sample Input:
3
1
2
3
Sample Output:
2
6
20
8579. BF_MODULUS
Problem code: MODULUS2
Problem
Given an integer n print all the possibilities of a%n.
Input
The first line consists of an integer t, the number of test cases followed by t lines containing an integer
n.
Output
For each test case print all the possibilities of a%n in descending order separated by a single space.
After each test case print a new line character. If there are no possibilities print "NOT POSSIBLE".
Input specifications:
0<t<=100
0<=N<=100
Time limit: 1 second
Example
Sample Input
2
1
2
Sample Output
0
10
Added by: cegprakash
Date:
2011-03-18
Time limit: 1s
Source limit:50000B
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: BF
Input
In the first line the number of testcases N<=35, then N lines with one positive integer i.
Output
One line with "F i +F i+1 +...+F i+9 +last digit of F i+246 " for each i.
Example
Input:
2135
Output:
1461821381552
Input
In the first line the number T (T<100) of test cases.
Then T lines with the space-separated n (1<=n<=50), x1 and y1.
Output
For each test case the space-separated x2 and y2.
Example
Input:
31 1 15 3 250 48 49
Output:
1 05 349 50
Input
In the first line the number T (T<100) of test cases. Then T lines with the space separated coordinates
(integer 0<=x,y<=100) of the three towns.
Output
For each test case the coordinates of the above specified point.
Example
Input:
22 2 1 1 2 11 0 0 0 2 1
Output:
1.78867513459 1.211324865411 0
Input
First line has integer T i.e number of test cases. ( T <= 1000 ). Next T lines has a number n ( 0 <= n <=
10^1000 ).
Output
For each n, output the required HQ0-9+-INCOMPUTABLE?! program( having + at least once )
which will give n as output. If there are multiple solutions, output any one of them. Output of each test
case must be in a single line. If you dont want to solve a test case, leave a blank line for it.
PS : No of test cases in 11 test files are respectively -> 10, 10, 100, 1000, 80, 20, 40, 500, 100, 50, 200
Update ( Dec/5/2012 ) : A small bug in judge which was causing internal error has been fixed. With
refinement in test files, all solutions have been rejudged.
Added by: XeRoN!X
Date:
2011-12-27
Time limit: 1s-10s
Source limit:50000B
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All
Resource: Variation of IPSC Problem
Input
The first line contains two integers, n and m, representing the numbers of nodes and edges in the
graph. 3 <= n <= 2000 and 3 <= m <= 40000. The nodes are numbered 1..n, but not necessarily in
any order. The next m lines contain pair of integers representing edges between two nodes. The list of
edges are not in any particular order.
Output
There should be one line output listing all valid independent nodes you found in the graph. The nodes
are separated by one space.
Example
Input:6 71 21 52 32 53 43 65 6Output:1 4 6
Input
The input begins with the HTML source of your SPOJ account page.
> The following line contains a number (C<100), which represents the number of SPOJ competitors to
consider.
> The remainder of the input consists of the HTML source of the (C) competitors account pages.
Output
Print a list of problem codes you have not yet attempted that a competitor has solved.
> Sort the list by the number of competitors that have solved the problem, then alphabetically to break
ties.<p>
Example
Input:
Preview
Output:
Preview
Score
Your CPU is old and can only store 512 characters. Minimize your source length.
Added by:
Date:
Time limit:
Source
limit:
Languages:
Resource:
Jared Deckard
2012-04-19
1s
512B
BASH C C# C++ 4.3.2 FORT HASK JS PERL PERL 6 PHP PYTH 2.5 PYTH 3.1.2
RUBY
Review the account page source code.
Input
first line has number t - number of test cases.
each test case has 4 numbers n m a d
Output
Single line having single number giving the count
Example
Input:
3
1 10 2 2
20 100 3 3
100 1000 4 5
Output:
5
54
543
NOTE - 1<=n<=m<= 2^32
1<=a<= 2^32
1<=d<=2^32
2<=t<=100
Input
first line of input will have number t indicating the number of test cases.
each of the test cases will have 2 lines
firts line will have 3 numbers a ,d and r
2nd line will have 2 numbers n & mod
a- first term of the AGS
Output
For each test case print "a(n)%mod" in a separate line.
Example
Input:
21 1 213 72 2 210 8Output:16 Description - for the first test case the series is 1,2,4,5,10,11,22,23,46,47,94,95,190..13th term is 190 and 190%7 = 1Note - the value of a , d , r , n & mod will be less than 10^8 and more than 0.for every series 2nd term will be a+d and third term will be (a+d)*r .. and so on ..
Added by:
Date:
Time limit:
Source
limit:
Cluster:
Devil D
2012-04-24
1s
10000B
What if you were given 2 random numbers as the starting of the series and u follow the same rule as
the Fibonacci rule.
for eg. if you were given 2 and 2 .. the series would become
2 2 4 6 10 16 26 .........
Input
first line will have single number t - number of test cases.
each test case will have 4 numbers a,b,n & M
a- first number of the series
b- second number of the series
n- calculate the sum till n numbers
M- print the result mod M
Output
single number for each case - sum of n terms mod M
Example
Input:
22 2 10 211 3 10 21Output:
134Explanation - for first case series is 2 2 4 6 10 16 26 42 68 110 .. Sum is 286.. o/p = 286%21 = 13NOTE -Number of test cases <=100.0 <= a,b<= 10^8
1 <= n,m <= 10^8
Added by:
Date:
Time limit:
Source
limit:
Cluster:
Devil D
2012-04-26
1s
4000B
Input
The first line contains the number of test cases, T.
The first line of each test case contains an integer N, the number of coeficients.
The second line contains the polynomial coeficients a N-1 , ..., a 1 , a 0 such that (P(x) = a N-1 x N-1 + ...
+ a 1 x 1 + a 0 x 0 ).
Output
The roots of the polynomial, in sorted order. That is all real numbersr 0 , r 1 , r 2 , ...such that P(r) = 0.
Constrains
T <= 20
N <= 20
All coeficients are in the inclusive range [-10 6 ,10 6 ]
The output precision must be at least 2 decimal digits
The roots must truly be real. No complex roots even if the imaginative part is very small.
Cases
1.
2.
3.
4.
5.
6.
7.
Example
Input:
4
3
1 0 -2
3
1 0 1
4
-1 3 -3 1
7
1 -1 -9 13 8 -12 0
Output:
-1.414214 1.4142135
1 1 1
-3 -1 0 1 2 2
x2 - 2
x2 + 1
-x 3 + 3x 2 - 3x + 1
x 6 - x 5 - 9x 4 + 13x 3 + 8x 2 - 12x
-sqrt(2), sqrt(2)
No real roots
Triple root in x=1
Mixed integer roots
Notes
1. All testcases a double checked using Mathematica with 30 digits of precision.
2. Constrains are set such that most approaches should be fine using double working precision.
Input
Theres no input for this task
Output
You should output 17 lines with: W(1), W(2), W(3), ..., W(17)
Example
Output:
8
95
... (15 lines follows)
Score
Score is source length, you have to use less than 190 bytes, the third should be enough.
Information
W(17) fit in a 64bit signed container, W(18) doesnt.
You may try M3TILE or M4TILE first.
After that, you may try those : Tiling a WxH Grid With Dominoes , Corridor I , Corridor II .
Input
Input consists of t (number of test cases), then t line follows, each containing an integer N (1 <= N <=
10,000).
Output
A single line containing the sum upto Nth integer (rounded upto 5 digits)
Example
Input:
512345Output:
0.333330.428570.461540.476190.48387
Edit: The score is your source length. The smaller your code is, the more point you will get. All
the solutions have been rejudged !!!
Added by: Better late than never !!!
Date:
2012-06-20
Time limit: 1s
Source limit:50000B
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All
Resource: RamjiLal Sir
Input
First line contains a integer t=number of test cases.
Then each test case contains a number n. and next line conatin n numbers separated by a space.
1<=n<=100
and the numbers are less than 10^18
Output
A single line for each test case as described above.
Example
Input:
1
5
-1 2 -3 5 -4
Output:
Every Girl Lies!
Note -- > Source Limit is made a little strict !!Surprised .. So chill out !!Laughing
Input
The first line is an integerT(1 <=T<= 10000), denoting the number of test cases. Then,Ttest
cases follow.
Each test case consist of 3 lines:
-first line contains two integer xand y(1 <= x,y<= 10)location of point A
-second line contains two integer x1(0 <= x1< x)and y1(1 <= y1<= y) location of point B
-third line contains two integerx2(1 <=x2<= x)andy2(0 <=y2< y) location of point C
Output
For each test case, output number of different shortest path from (0,0) to point A but not through point
B and C.
Example
Input:
2
4 5
3 4
2 2
3 3
2 1
1 2
Output:
32
2
Input
The first line is an integerT(1 <=T<= 276), denoting the number of test cases. Then,Ttest cases
follow.
For each test case, there are two integers Wand H(0 <= W+H<= 22)written in one line, separated
by space.
Output
For each test case, output the number of different ways to tile a W-by-H grid with (2x1)dominoes.
Example
Input:
6
1 2
2 3
3 4
4 5
5 6
6 7
Output:
1
3
11
95
1183
31529
Information
All outputs will fit on 64-bit signed integer and less than 10 15 .
You may try M3TILE, M4TILE, or M5TILE first.
Input
There are multiple test cases, each line contain an integer i(0 <i< 2 64 ). Process input until EOF.
Output
For each case, output the converted number in separate line.
Example
Input:
137
1315
Output:
137=2(2(2)+2+2(0))+2(2+2(0))+2(0)
1315=2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)
Input
The first line will contain a single value T, for the number of tests to follow, where T <= 100.
For each test there will be three lines:
The first line will contain three entries indiciating: the Walzenlage, the Ringstellung,and the
Grundstellung in the form 123 AAA BBB. The Walzenlageonly contains numbers 1-5. The
Ringstellungand Grundstellungwill be provided as triplets of letters in the range A-Z.
The second line will contain pairs of letters, from the range A-Z, indicating the settings for the
Steckerbrett- there may be up to 13 pairs of letters.
The final line of the test will contain an unknown length message to encode/decode - the message
will be in the standard quintuple form used at the time, separated with spaces,eg ABCDE
FGHIJ KL. The final group may be 1-5 letters in length. Again, only the range of letters A-Z will
be used. The line will be terminated in a newline (0x0A).
The Enigma machine used is the three rotor M3 version. This had five rotors, of which only three
would have been installed at any time. The Umkehrwalzein use is the B wiring.
Output
The output is to match the third line of the input, i.e. must be in the same quintuple grouping. One line
of output per message is to be produced.
Example
Input:
2
123 JAN DER2
123 JAN DER
SP OJ RU LZ
THISX ISXAN XEXAM PLEXI NPUT
543 SPO JPL
SH OR TE NI
YUQKD YVPSF HCQEI VHAPE NAQZQ I
SP OJ RU LZYUQKD YVPSF HCQEI VHAPE NAQZQ I
Output:
SJLKM SVZYM HXTUW VVWYY EDEB
THISX ISXAX DECOD XEDXM ESSAG E
Anjali and Nakul are good friends. They had quarrelled and you had written a program for Anjali to know theminimum number of moves a knight takes to reach from one square to another square of a chess board(8X8).Nakul is brilliant and knows Anjali didnt write it herself and says her program is too slow by all standards. He isunimpressed so she asks you to try solve the problem faster this time using as few keystrokes as possible.She wants to know whether you can actually do it. Anjali is very weak in programming. Help her to solve theproblem.Since you are busy and tend to forget she reminds you that "A knight can move in the shape of an "L" in a chessboard - two squares either forward, backward, left, or right and then one square to its ...Since you are busy and tend to forget she reminds you that-"A knight can move in the shape of an "L" in a chessboard - two squares either forward, backward, left,or right and then one square to its left or right. A knight move is valid if it moves as mentioned above andit is within the boundary of the chessboard (8 X 8)."first solve problemhttp://www.spoj.pl/problems/NAKANJ/
a1 h8
a1 c2
h8 c3
Output:
614
Score:
Your source code length (if you are successful in avoiding TLE and WA)
Input
There are T test cases in total. The next T lines contain two strings (start and destination) separated by aspace.T<=200001The strings start and destination will only contain two characters - First character is an alphabet betweena and h (inclusive), Second character is a digit between 1 and 8 (inclusive) - (Quotes just for clarity).
Output
Print the minimum number of moves a knight takes to reach from start to destination in a separate line.
Exam
X
3
9
19
where each new line is the minimal D to break a new record for X.
E.g : for any D in [5, 10[, X(D) will be not greater than 19.
The search and print of those pell-fect (D, X) is the goal of this challenge.
Input
Theres no input for this challenge.
Output
Start with D=2 and X=3, and print consecutive pell-fect "D X" of this sequence. As the answer X
could be a huge number, print instead CHK(X, 2^16384), this only affect X numbers on line 127 and
after.
Example
Output:
2 3
5 9
10 19
[...]
constraints
This is madness, but XerK can judge 1000 lines.
Score
If you can output n lines, XerK decided that the fairest score was exp(sqrt(n)), but he didnt want to
tell why, so it was decided to set the score at just n. You need to output more than 44 lines to get
accepted.
Added by: Francky
Date:
2012-12-01
Time limit: 44s
Source limit:50000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: Own problem
Input
First line : T ( No of test cases ) <= 20. Each test case starts with N and K i.e. number of buildings in
Metropolis and number of Zods Robots respectively. Next N lines have two integers i.e. x and y
coordinates of each building.
3 <= N <= 10^5 and 2 <= K <= minimum(N, 1000) and ( 0 <= x <= 10^6, 0 <= y <= 10^6 ) and T*N
<= 2*10^5
Output
For each test case output "Save" K and then K lines, each having index of the building in the input (
see example ). It is obvious but stating it explicitly that for each test case:
Example
Input:
24 30 00 11 12 23 21 11 29 9Output:Save 312 4Save 212Score : Average of S/A over all test cases. [ minimize the score ]
Score for the first test case = [pairwise distance between A(0,0), B(0,1), C(2,2)]/1.3106...
Input
First line, theres an integer T(1 <= T<= 10,000) then Tcases follow.
Each test case theres an integer n(4 <= n<=10,000,000).
Output
For each test case, output xand ywith this fotmat: x*y. see the examples for more detail.
Example
Input:
6
4
10
15
20
321
1020
Output:
1*4
4*9
3*12
8*18
245*320
864*1014
Input
there are 10 test cases ... in each one there is:
one_digit_number a
followed by space
then one_digit_number b
followed by end_of_line charachter
Output
the logic value of a==b
Example
Input:4 78 89 70 1..Output:0100..Score is your Code Length.
Input
The first line contains two integers, n and m, representing the numbers of nodes and edges in the
graph. 3 <= n <= 2000 and 3 <= m <= 40000. The nodes are numbered 1..n. The next m lines contain
pair of integers representing edges between two nodes. The list of edges is not in any particular order.
Output
There should be only one line of output, listing all valid nodes in the vertex cover you found in the
graph. The nodes are separated by one space.
Example
Input:6 71 21 52 32 53 43 65 6
Output:
5 3 2
0
1
0
1
0
0
0
1
0
BE CAREFUL: ONLY BRAINF*** AVAILABLE FOR SUBMIT .
ENJOY ;)
Note : maybe it will be helpful for you to know that a never equal to b in the test cases ;)
Added by: Mostafa 36a2
Date:
2012-12-27
Time limit: 1s-5s
Source limit:2000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: BF
Resource: BF it self ^_^
13172. Good
Problem code: GOV02
The problem is very easy.
You are given n terms ( the terms can be integer as well as floating ). Let S = sum of all the n terms. A
number k (x<=k<=y) is said to be good if S is divisible by it.
Input
Input begins with an integer t.
Then t test cases follow.
For each test case, three numbers n,x,y are given. Then n terms of the sequence follow.
(REMEMBER: all the input is on a single line)
Output
For each test case,
You have to output a single integer m.
where, m = (sum of all even good numbers) - ( number of all odd good numbers)
(REMEMBER: all the output should be on a single line)
The numbers should be separated by spaces.
Example
Input:
2 3 1 2 1 2 3 4 1 10.5 -1 4.5 4.5 4
Output:
1 10
Scoring:
Your task is to minimise the source code length.
The less your fingers work, more you gain.
Remember:
Only python 2.7 is permitted.Sorry in advance, I will not allow any other language.
Source limit is tight. So be careful.
Constraints:
1<=t<=10
1<=n<=100
-100<=any term of sequence<=100
0<x<=y<=100
output:
the value of(a mod b)
Example1:
input:
999 2
output:
1
Example2:
input:
005 6
output:
5
Example3:
input:
099 1
output:
0
Score:
note: you can see how the judge read your code at your submission info (only the first test file).
LAST UPDATE NOTE 15/1/2012:
Ive complete improving test files ... there is now 59 test files ,also now you can write 100,000 byte
code
after solving the problem,maybe you can see that MCLT: MORE CODE --> LESS TIME Wink
Enjoy :)
Added by: Mostafa 36a2
Date:
2013-01-07
Time limit: 1s
Source limit:100000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: BF
Resource: FizzBuzz Happy 2013
Input
The first line, there is an integer T(1<=T<=100)denoting number of test cases then you should
process only next Tlines, each line is a <string> terminated by new line character (\n) ASCII(10)
Output
For each test case:
if <string> is palindrome, output: YES
else, output: NO
Example
Input:
2
aba
ab
Output:
YES
NO
Score
Score is length of your source.
If you TLE here, you may trythis problemfirst. If you got AC in 0.00s there you shoud got AC in
0.00s here too Wink
See also: Another problem added by Tjandra Satria Gunawan
Added by: Tjandra Satria Gunawan
Date:
2013-01-10
Time limit: 0.009s
Source limit:1500B
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: BF
Resource: The Mirror of Galadriel Problem plus my own idea ;-)
Input Constraints:
1<=t<=50
1<=a,b,c<=50
Sample Input:
3
235
OXOOO
OOXXX
XXXXO
<- empty line just for clarity.
XOXOO
XOOXO
OXXOX
116
OXOXXO
113
OOO
Sample Output:
X
O
O
Explanation:
Case 1: King 1 wins in his first move by attacking any enemy region.
Case 2: King 2 can win if he is intelligent.
Case 3: King 2 already won.
Output
You have to output 1001 lines, the factorization of the 1001 first terms of the Fibonacci sequence. See
sample for output details.
Example
F(0)= 0
F(1)= 1
F(2)= 1
F(3)= 2
F(4)= 3
F(5)= 5
F(6)= 2^3
F(7)= 13
F(8)= 3 * 7
F(9)= 2 * 17
F(10)= 5 * 11
F(11)= 89
F(12)= 2^4 * 3^2
[...]
F(1000)= 3 * 5^3 * 7 * 11 [...]
13423. 64bit-Fibonacci
Problem code: FIB64
Warning
This task is intended to help people to debug their codes and try speed experiments.
The task is the same as in some known problems, but with new constraints and speed goal.
The Fibonacci sequence is defined for any positive integer number by : If N<2: Fib(N)=N, else
Fib(N)=Fib(N-1)+Fib(N-2)
You have the task of being the fastest to compute Fib(N) mod M.
Input
The input consists of 500000 lines. In each the 500000 lines there are two integer numbers N, M.
Output
For as many test cases you can, on a single line, print Fib(N) mod M.
Example
Input:
5 4
5 5
5 6
[...]
Output:
1
0
5
Constraints
0 <= N <= 10^18
2 <= M <= 10^18
Score
As in the example, if you can output the 3 first correct answers, your score will be 3 points. No need to
solve all the input, the minimum is 1 ; every solver in any language will be able to check his
FIB64-speed.
Added by: Francky
Date:
2013-01-20
Time limit: 1s
Source limit:50000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: Own problem
B
H
N
T
Z
6
C
I
O
U
1
7
D
J
P
V
2
8
E
K
Q
W
3
9
F
L
R
X
4
0
[Enter]
Input
The input consists of 666666 lines. In each the 666666 lines there are two integer numbers N, M.
Output
For as many test cases you can, on a single line, print the number of different passwords of length N.
As the answer could be an enormous number, output the answer modulo M.
Example
Input:
1 10
2 100
987654321123456789 1000000000
[...]
Output:
6
20
831617808
Explanations
For a one key password, there are 36 possibilities, answer modulo 10 is 6. For a two keys password,
there are 120 possibilities, answer modulo 100 is 20. For the last case, the answer has around
510^1^7 digits, the nine last ones are 831617808.
Constraints
1 <= N <= 10^18
2 <= M <= 10^9
Theres one input file, and data are uniform-randomly chosen in their range.
Score
As in the example, if you can output the 3 first correct answers, your score will be 3 points. No need to
solve all the input, the minimum is 1 ; every solver in any language will be able to check his
SPPconstant-speed.
Added by: Francky
Date:
2013-02-22
Time limit: 1s
Source limit:50000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: Own problem
Input
N testcases (no more than 100)
Each line of the input contains the keyword and a plaintext.
The keylength max is 100 and the length of the plaintext is limited to 200.
The last testcase ends with EOF.
Output
Output consist of exactly N lines of cyphertexts with letters in [A-Z] with no spaces.
Example
Input:JIMMORRISON RIDERSONTHESTORMINTOTHISHOUSEWEAREBORN
Output:
OQVNTNMGVXJNQAWKEHMELHKJQQNJWKSJURUSOUCAHOV
Input
The first line contains an integer number W : the size of the squared matrix. The W next lines contains
W integer numbers Mij : the coefficients of the matrix, line by line. In each the 838383 next lines there
are three integer numbers I, J, N. You dont have to read the whole input, just as many as you can
solve...
Output
For as many test cases you can, on a single line, print the coefficient on the Ith line, Jth column of the
matrix M^N (M to the power N). As the answer could be a big number, output the answer modulo
1000000007.
Example
Input:
5
32 82 7 66 30
57 1 28 2 89
53 66 6 35 61
45 87 88 24 20
35 22 23 80 93
1 1 1
1 5 2
5 1 3
5 5 99
[...]
Output:
32
12795
2714937
764817976
Explanations
For the first case: M^1 =
32
57
53
45
35
82 7 66 30
1 28 2 89
66 6 35 61
87 88 24 20
22 23 80 93
2282253
2029855
2375941
2551827
2953573
1259668
1625446
1532239
1589794
1948704
2181834
1781368
2245976
2622329
2545886
3027095
2477165
3026032
3550751
3742082
Constraints
W
1
1
1
= 18
<= I,J <= W
<= Mij <= 10^9
<= N <= 10^18
Score
As in the example, if you can output the 4 first correct answers, your score will be 4 points. No need to
solve all the input, the minimum is 1 ; every solver in any language will be able to check his
MATrix-EXponentiation-speed.
Added by: Francky
Date:
2013-02-27
Time limit: 1s
Source limit:50000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: Own problem
Input
First line of input contains an integer t representing the number of test cases. Then t lines follows.
Each line contains an integer R.
t<=8000
R<=10000
Output
Output should be of the format:
Integer 1<space>@<space>Integer2
Integer 1: Number of primes equation n 2 +an+b produces for consecutive value of n, starting from
n=0.
Integer 2: absolute product of the coefficients, a and b.
Output of each test case should be on separate line.
Scoring
Lesser your fingers work, better it is. :-)
(Minimize your source code length)
Example
Input:
2
41
5
Output:
41 @ 41
5 @ 5
Explanation:
case 1: a=-1 b=41
case 2: a=-1 b=5 ( Here n=0 and n=1 produces same prime 5, but we will count it twice)
Input
The first line of input contains an integer T, the number of test cases. On each of the next T lines, your
are given three integers N, M and K such that: N = a + b M = a 2 + b 2 - (2K-2)ab
with a > 0, b > 0 and gcd(a, b) = 1.
Output
For each test case, you have to print gcd(N, M), the greatest common divisor.
Example
Input:
2
2214811 1451126169481 7
107603 9066347749 9
Output:
1
1
Note: For the first trio a = 117651 and b = 2097160. For the second a = 1313 and b = 106290.
Constraints
0
0
1
0
<
<
<
<
T
N
M
K
<
<
<
<
14321
10^200
10^200
17
For your information, my 293B C code get AC in 0.03s with 1.6MB of memory print. Size code limit
will be 666B. Language restrictions are quite the same than in GCD3, and it is justified ;-) Have fun
;-)
Input
Text file containing printable ASCII only with size<1MB.
Output
Brainf**k code that print that text file.
Score
Your score is: Sum of all BF code length in all test data
Example
Input:
Hello World!
Output:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]
>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Your Score (BF Code Length, valid command only):
111
Note: This is the first time I make my own judge, Ive tested it hundred times with various test data,
and so far no bug is found (found some but has been fixed). If you found a bug, you can send me info
via PM or email, Ill fix that as soon as possible. Btw, here is the judge for this problem, maybe itll be
useful information for you. Good Luck and Have Fun :-D
See also: Another problem added by Tjandra Satria Gunawan
Added by: (Tjandra Satria Gunawan)(???)
Date:
2013-05-25
Time limit: 22s
Source limit:50000B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: This problem is purely came from my own idea \(^_^)/
Input
The first line there is an integer Tdenoting number of test case.
Next Tlines there are two integers nand k for each line, n and khas been described above.
Output
For each test case, output an integer that is the desired answer that has been described above.
Constraints
1 <= T<= 10 5
1 <= k<= 10 9
k <= n <= 10 9
Example
Input:
3
1 1
2 1
2 2
Output:
0
0
1
Explanation
For first and second test case it has one different element so it already sorted, no need to do any swap
operation.
For second test case if the element is decreasing (this is the worst case), only one swap is needed, then
the sort is complete.
Other Info
Score is your source length.
Seems that its impossible to solve this problem using some programming languages e.g(Brainf**k,
Intercal, etc).
Click here to see my score for this problem (Link has been updated after rejudge)
See also: Another problem added by Tjandra Satria Gunawan
Added by: (Tjandra Satria Gunawan)(???)
Date:
2013-08-11
Time limit: 10s
Source limit:200B
Cluster:
Cube (Intel Pentium G860 3GHz)
Languages: All
Resource: Own Problem