Академический Документы
Профессиональный Документы
Культура Документы
BDOI2007
Bangladesh Olympiad in Informatics
Arranged by BRAC University BRAC University Computer Club Bangladesh Informatics Olympiad Committee
Page 1 of 13
ex + e x + e"x = 00!
PROBLEM D. MA#E MADNESS
Oops) *ou are stuc+ in a ma,e) *ou have to get free from the ma,e in minimum number of steps# In one step you can move up( do%n( right or left# *our starting position is denoted by -&.# A bloc+ed cell /a cell %here you can not step into0 is represented by a -1. and -#. represents a free cell# -2. represents your destination# #################################################### #S..............#........###.......................# #..####..####...###..###########.####.####.####....# #..#...#.#...#.#...#...#.......#.#..#.#..#....#....# #..#..#..#...#.#...#...#....####.#..#.#..#....#....# #..#...#.#...#.#...#...#....#....#..#.#..#....#....# #..####..####...###..#####..####.####.####....###### #....#.###....##.................#.......#.........# #....#.....#.....#..##############.####..########### #.###...#..#.#######........#...........#.####.....# #...#.###..#........####..##...#........#......#.#.# #.#....#.#..#.###.....##.....############..#######.# #...#..#............#.....#....................#..D# ####################################################
Page 3 of 13
INPUT:
8here %ill be only one line in the input containing 9 integer values $1( y1( $3( y3( $3( y3# Absolute value of each integer %ill be %ithin 1""#
OUTPUT:
Output should contain only one line( :*es; if it is a right angled triangle( :<o; other%ise# /'ithout the =uotes0
SAMPLE INPUT 1:
0 0 0 1 1 0
10 10 20 20 30 10
REMARK:
8ry to solve this problem using integer calculation#
Page 3 of 13
PROBLEM $.
INPUT:
*ou are given < integers# *ou have to find out ho% many of them are positive( negative or ,ero# Input %ill consist of 3 lines# irst line %ill consist of the integer < /" > < > 1"10# In the ne$t line( there %ill be < integers in the range /61""( 1""0#
OUTPUT:
Output should contain 3 integers in a line separated by a single %hite space# 1st integer is the count of positive numbers( 3nd integer is the count of negative numbers and 3rd integer is the count of ,eros#
SAMPLE INPUT 1:
3 0 1 1
SAMPLE INPUT 2:
10 1 2 3 4 5 6 7 8 9 10
SAMPLE INPUT 3:
5 -1 0 -1 -5 0
Page ! of 13
INPUT:
Input %ill contain only one integer( <( the number of pieces &uper Aulu has#
OUTPUT:
Output only the ma$imum dimension of the bottom layer#
SAMPLE INPUT 1:
34
SAMPLE INPUT 2:
57
REMARKS:
1 E < E 1("""("""("""
Page C of 13
INPUT:
8here %ill be only one line in the input# Inde$ of the month( n 4 " > n > 1"""""""""5#
OUTPUT:
Output should contain only one line( number of rabbit pairs in the nth month by modulo 1""""#
SAMPLE INPUT 1:
1
SAMPLE INPUT 2:
10
SAMPLE INPUT 3:
28
REMARKS:
In 3"H test casesI " > n > !9# In J"H test casesI " > n > 1""""""#
Page 9 of 13
PROBLEM I.
In an e$hibition a diamond is +ept in high security# And you +no% KA&BR light is usually used in such security system# In our problem %e %ill consider that all the lights are at same plane parallel to hori,on so that %e can represent the lights as straight line in a 32 plane# *ou have to tell me the number of points through %hich more than one light passes# 8he figure on the right represents sample 3#
INPUT:
In the first line( there %ill be given a positive integer < 4number of KA&BR lights5 /" > < > 1"""0# In each of the follo%ing < lines( there %ill be 3 integers a i( bi and ci %hich represent a KA&BR light on a 32 plane# 4ai$ L biy M ci5
OUTPUT:
Output should contain only one line( number of intersection points of the KA&BR lights#
SAMPLE INPUT 1:
1 1 0 0
SAMPLE INPUT 2:
2 1 0 0 0 1 0
SAMPLE INPUT 3:
6 -1 1 0 -1 1 -4 0 1 -2 1 1 0 1 0 -2 1 0 2
REMARKS:
In 3"H test casesI " > < > C"# In J"H test casesI " > < > 1""#
Page J of 13
PROBLEM '.
*ou are given a map# In the map( -1. denotes land and - .. denotes %ater# 8%o islands belong to same country if the minimum distance bet%een them is not more than one unit# 8he distance is defined by the shortest path through %ater bet%een them# 8ell me ho% many countries are there in the map) In the Nap 1 and Nap 3( the t%o islands are neighboring as you can see that the minimum distance bet%een them is 1 unit %hich is sho%n by the bold line# But in the Nap 3( there is no such path# Nap 1 Nap 3 Nap 3
INPUT:
In the first line( there %ill be given R and C representing the ro%s and columns of the map respectively# / " > R( C > 1"""0 In the follo%ing R lines( there %ill be C characters each of %hich is either -1. or - ..#
OUTPUT:
Output should contain only one line( number of countries in the map#
SAMPLE INPUT 1:
3 3 ### ... #.#
SAMPLE INPUT 2:
5 5 #..## ...## #.... ....# ..#..
REMARKS:
In C"H test casesI " > R( C > 1""#
Page O of 13
INPUT:
In the first line( the characters 4that are hanging in front of G5 are given /%ithout space0# In the second line( P number of %ords in the list of the instructor is given# /P > 1"""0 In the follo%ing P lines( there %ill be given a %ord /%ithout space0# 8he initial board configuration and the %ords all %ill have at most 1""" length#
OUTPUT:
Output should contain only one line( probability of success of G in aQb form( %here a and b are co6prime /i#e# AC2 M 10# 4*ou may assume that the probability %ill never be ,ero#5
SAMPLE INPUT 1:
ItIs4:22AM 5 II st am It I4
SAMPLE INPUT 2:
Page R of 13
PROBLEM L.
ENCODE,EDOCNE
:8oday I am going to give you an assignment;( said teacher# :<o sir( no) 'e have 3 class tests in this %ee+); :<o) *ou have to do it by tomorro%); :<o sir( please###############; :*ou %ill be given a string# 8hen %rite do%n the string( you get by rotating the given string one unit on right( ?ust belo% the first string# And then %rite do%n another one rotating initial string t%o units to right# And so on# 8his process %ill continue K61 times %here K is the length of the given string# *ou have to output the right6most column of the grid you get#; or e$ample( if the given string isI BRAC then after rotating one unit to right it %ill become CBRA( and one more( ACBR and one more( RACB# 8hus the resulting grid %ill loo+ li+eI BRAC CBRA ACBR RACB And thus the right6most column isI :CARB;
INPUT:
In the first line( there %ill be a string %ithout space# Kength of the string %ill be at most 1""""""#
OUTPUT:
Output should contain only one line( the last column of the grid you got by follo%ing the above %ay#
SAMPLE INPUT 1:
'(A)
SAMPLE INPUT 2:
AAAAA
SAMPLE INPUT 3:
)A*
REMARKS:
In C"H test cases( Kength of the string %ill be at most 1"""#
Page 1" of 13
INPUT:
In the first line( there %ill be given the phone number < /< > 1"""""""""0#
OUTPUT:
Output should the command lines#
SAMPLE INPUT 1:
5891
SAMPLE INPUT 2:
40
Page 11 of 13
INPUT:
8he first line of the input contains the integer <# 8hen there follo%s < integers representing the se=uence of notes#
OUTPUT:
8he output should contain a single line %ith a single integer that represents the length of the longest theme# If there are no themes( output "#
SAMPLE INPUT 1:
30 25 27 30 34 39 45 52 60 69 79 69 60 52 45 39 34 30 26 22 18
82 78 74 70 66 67 64 60 65 80
Page 13 of 13
INPUT:
irst line contains t%o integers( n( the total number of persons and +( your position# <e$t n lines contain one integer each( their arrival time#
OUTPUT:
Output t%o integersI earliest time and latest time separated by a space#
SAMPLE INPUT 1:
5 3 -1 2 1 3 3
REMARKS:
n E 1""(""" 1EnE+ 61""("""(""" E arrival time E 1""("""("""
Page 13 of 13