Three Lines [Brian Dean, 2012] Farmer John wants to monitor his N cows (1 <= N <= 50,000) sin! a new sr"ei##ance s$stem he has %rchase&' The ith cow is #ocate& at %osition (i, $i) with inte!er coor&inates (in the ran!e 0'''1,000,000,000)* no two cows occ%$ the same %osition' FJ+s sr"ei##ance s$stem contains three s%ecia# cameras, each o which is ca%a-#e o o-ser"in! a## the cows a#on! either a "ertica# or hori.onta# #ine' /#ease &etermine i it is %ossi-#e or FJ to set % these three cameras so that he can monitor a## N cows' That is, %#ease &etermine i the N #ocations o the cows can a## -e sim#taneos#$ co"ere& -$ some set o three #ines, each o which is oriente& either hori.onta##$ or "ertica##$' [Note %ro!rams that &o nothin! more than mae ran&om !esses a-ot the ot%t ma$ -e &is3a#iie&, recei"in! a score o .ero %oints] /4BL67 N876 9#ines :N/;T F478T Line 1 The inte!er N' Lines 2''1N Line i1 contains the s%ace>se%arate& inte!er i an& $i !i"in! the #ocation o cow i' ?87/L6 :N/;T @ 1 0 1 2 1 9
A 0 2 0
:N/;T D6T8:L? There are @ cows, at %ositions (1,A), (0,0), (1,2), (2,0), (1,), an& (9,)' ;T/;T F478T Line 1 /#ease ot%t 1 i it is %ossi-#e to monitor a## N cows with three cameras, or 0 i not' ?87/L6 ;T/;T 1 ;T/;T D6T8:L? The #ines $=0, =1, an& $= are each either hori.onta# or "ertica#, an& co##ecti"e#$ the$ contain a## N o the cow #ocations'
4Lay T3Xt 6En3Rat0r Anda diminta membuatkan sebuah program yang bernama, "ALAY TEXT GENERAT GENERATOR" dimana memudahkan orang-orang aay seperti anda untuk memakainya! Tet Tet aay dihasikan meaui penggantian beberapa karakter men#adi angka, dan menggunakan seed untuk menghasikan huru$ besar yang a%ak! &erubahan karakter men#adi angka berdasarkan tabe diba'ah ini( Karakter
Angka
o
)
i
*
+
e
a
.
s
/
g
0
#
1
b
2
3
4
5edangkan huru$ besar dihasikan meaui seed-seed biangan, untuk tiap indeksi6muai dari *7 karakter 8a8!!8+8 diakukan perhitungan yaitu #ika pada i mempunyai #umah keipatan seed-seed seed-seed biangan gan#i maka maka karakter diganti men#adi huru$ huru$ besar, #ika tidak maka huru$ tetap tetap huru$ ke%i! 9ntuk karakter karakter seain 8a8!!8+8, karakter tidak dimanipulasi. Spesifikasi Masukan
:asukan terdiri dari baris yaitu( ;aris pertama terdiri dari * buah biangan yaitu 6* <= n <= )7 menyatakan banyaknya seed! ;aris kedua terdiri dari n buah biangan masing-masing merupakan seed! ;aris ketiga merupakan tet yang akan ditrans$orm ke tet aay! >aimat terdiri dari
karakter 8a8!!8+8, titik6!7, koma6,7, dan spasi6 7! &an#ang kata tidak meebihi )) karakter! Spesifikasi Keluaran
5atu baris keuaran yaitu Tet Aay yang dihasikan! !nt!" Masukan 9 A 19 2C the 3ic -rown o m%s o"er the #a.$ &o!'
!nt!" Keluaran th9 C;1cE 40GN 0 A;m/5 0H94 tI9 L2$ &0@'
#en$elasan
>arakter 8a8!!8+8 yang diakukan perubahan upper ? o'er %ase hanya pada karakter yang tidak bisa direpa%e dengan angka!
inde%
karakter
'
3 & '3 ()
$umla"
status
t
0
genap
(
"
0
genap
3
e
'
gan$il
0
genap
0
genap
'
gan$il
'
gan$il
0
genap
'
gan$il
0
genap
0
genap
'
gan$il
'
gan$il
'
gan$il
'
gan$il
0
genap
0
genap
'
gan$il
@
4 *
+
6
u
&
i
,
-
)
k
@ @ @
'0 ''
'(
r
'3
!
'4
/
'*
n
@ @ @ @
'6 '&
f
',
!
@
')
%
(0
@ @
0
genap
0
genap
(
genap
('
$
((
u
0
genap
(3
m
0
genap
(4
p
'
gan$il
(*
s
0
genap
'
gan$il
'
gan$il
'
gan$il
'
gan$il
'
gan$il
0
genap
0
genap
'
gan$il
0
genap
'
gan$il
'
gan$il
@ @
(6 (&
!
(,
()
e
30
r
@ @ @ @
3' 3(
t
33
"
34
e
@ @
3*
@
36
l
3&
a
0
genap
3,
1
0
genap
3)
y
(
genap
0
genap
0
genap
(
genap
@
40
@
4'
d
4(
!
43
g
0
genap
44
.
0
genap
@ @
Ba#ance& ow ?-sets [Nea# G, 2012] Farmer John+s owns N cows (2 <= N <= 20), where cow i %ro&ces 7(i) nits o mi# each &a$ (1 <= 7(i) <= 100,000,000)' FJ wants to stream#ine the %rocess o mi#in! his cows e"er$ &a$, so he insta##s a -ran& new mi#in! machine in his -arn' ;nortnate#$, the machine trns ot to -e ar too sensiti"e it on#$ wors %ro%er#$ i the cows on the #et si&e o the -arn ha"e the eact same tota# mi# ot%t as the cows on the ri!ht si&e o the -arnK Let s ca## a s-set o cows -a#ance& i it can -e %artitione& into two !ro%s ha"in! e3a# mi# ot%t' ?ince on#$ a -a#ance& s-set o cows can mae the mi#in! machine wor, FJ won&ers how man$ s-sets o his N cows are -a#ance&' /#ease he#% him com%te this 3antit$' /4BL67 N876 s-sets :N/;T F478T Line 1 The inte!er N' Lines 2''1N Line i1 contains 7(i)' ?87/L6 :N/;T 1 2 9 :N/;T D6T8:L? There are cows, with mi# ot%ts 1, 2, 9, an& ' ;T/;T F478T Line 1 The nm-er o -a#ance& s-sets o cows' ?87/L6 ;T/;T 9 ;T/;T D6T8:L? There are three -a#ance& s-sets the s-set 1,2,9M, which can -e %artitione& into 1,2M an& 9M, the s-set 1,9,M, which can -e %artitione& into 1,9M an& M, an& the s-set 1,2,9,M which can -e %artitione& into 1,M an& 2,9M'
Booshe# [Nea# G Tra&itiona#, 2012] Ghen Farmer John isn+t mi#in! cows, stacin! ha$-a#es, #inin! % his cows, or -i#&in! ences, he eno$s sittin! &own with a !oo& -oo' "er the $ears, he has co##ecte& N -oos (1 <= N <= 100,000), an& he wants to -i#& a new set o -ooshe#"es to ho#& them a##' 6ach -oo i has a wi&th G(i) an& hei!ht I(i)' The -oos nee& to -e a&&e& to a set o she#"es in or&er* or eam%#e, the irst she# sho#& contain -oos 1''' or some , the secon& she# sho#& start with -oo 1, an& so on' 6ach she# can ha"e a tota# wi&th o at most L (1 <= L <= 1,000,000,000)' The hei!ht o a she# is e3a# to the hei!ht o the ta##est -oo on that she#, an& the hei!ht o the entire set o -ooshe#"es is the sm o the hei!hts o a## the in&i"i&a# she#"es, since the$ are a## stace& "ertica##$' /#ease he#% FJ com%te the minimm %ossi-#e hei!ht or the entire set o -ooshe#"es' /4BL67 N876 -ooshe# :N/;T F478T Line 1 Two s%ace>se%arate& inte!ers N an& L' Lines 2''1N Line i1 contains two s%ace>se%arate& inte!ers I(i) an& G(i)' (1 <= I(i) <= 1,000,000* 1 <= G(i) <= L)' ?87/L6 :N/;T (i#e -ooshe#'in) 5 10 5 A C 2 5 19 2 9 :N/;T D6T8:L? There are 5 -oos'
6ach she# can ha"e tota# wi&th at most 10'
;T/;T F478T Line 1 The minimm %ossi-#e tota# hei!ht or the set o -ooshe#"es' ?87/L6 ;T/;T 21 ;T/;T D6T8:L?
There are 9 she#"es, the irst containin! st -oo 1 (hei!ht 5, wi&th A), the secon& containin! -oos 2'' (hei!ht 19, wi&th C), an& the thir& containin! -oo 5 (hei!ht 9, wi&th )'
Booshe# [Nea# G Tra&itiona#, 2012] Ghen Farmer John isn+t mi#in! cows, stacin! ha$-a#es, #inin! % his cows, or -i#&in! ences, he eno$s sittin! &own with a !oo& -oo' "er the $ears, he has co##ecte& N -oos (1 <= N <= 2,000), an& he wants to -i#& a new set o -ooshe#"es to ho#& them a##' 6ach -oo i has a wi&th G(i) an& hei!ht I(i)' The -oos nee& to -e a&&e& to a set o she#"es in or&er* or eam%#e, the irst she# sho#& contain -oos 1''' or some , the secon& she# sho#& start with -oo 1, an& so on' 6ach she# can ha"e a tota# wi&th o at most L (1 <= L <= 1,000,000,000)' The hei!ht o a she# is e3a# to the hei!ht o the ta##est -oo on that she#, an& the hei!ht o the entire set o -ooshe#"es is the sm o the hei!hts o a## the in&i"i&a# she#"es, since the$ are a## stace& "ertica##$' /#ease he#% FJ com%te the minimm %ossi-#e hei!ht or the entire set o -ooshe#"es' /4BL67 N876 -ooshe# :N/;T F478T Line 1 Two s%ace>se%arate& inte!ers N an& L' Lines 2''1N Line i1 contains two s%ace>se%arate& inte!ers I(i) an& G(i)' (1 <= I(i) <= 1,000,000* 1 <= G(i) <= L)' ?87/L6 :N/;T 5 10 5 A C 2 5 19 2 9 :N/;T D6T8:L? There are 5 -oos'
6ach she# can ha"e tota# wi&th at most 10'
;T/;T F478T Line 1 The minimm %ossi-#e tota# hei!ht or the set o -ooshe#"es' ?87/L6 ;T/;T 21 ;T/;T D6T8:L? There are 9 she#"es, the irst containin! st -oo 1 (hei!ht 5, wi&th A), the secon& containin! -oos 2'' (hei!ht 19, wi&th C), an& the thir& containin! -oo 5 (hei!ht 9, wi&th )'
ows in a 4ow [Brian Dean, 2012] Farmer John+s N cows (1 <= N <= 1000) are #ine& % in a row' 6ach cow is i&entiie& -$ an inte!er -ree& :D* the -ree& :D o the ith cow in the #ine% is B(i)' FJ thins that his #ine o cows wi## #oo mch more im%ressi"e i there is a #ar!e conti!os -#oc o cows that a## ha"e the same -ree& :D' :n or&er to create sch a -#oc, FJ &eci&es remo"e rom his #ine% a## the cows ha"in! a %artic#ar -ree& :D o his choosin!' /#ease he#% FJ i!re ot the #en!th o the #ar!est consecti"e -#oc o cows with the same -ree& :D that he can create -$ remo"in! a## the cows ha"in! some -ree& :D o his choosin!' /4BL67 N876 cowrow :N/;T F478T Line 1 The inte!er N' Lines 2''1N Line i1 contains B(i), an inte!er in the ran!e 0'''1,000,000' ?87/L6 :N/;T C 2 A 9 A A 9 A 5 A :N/;T D6T8:L? There are C cows in the #ine%, with -ree& :Ds 2, A, 9, A, A, 9, A, 5, A' ;T/;T F478T Line 1 The #ar!est si.e o a conti!os -#oc o cows with i&entica# -ree& :Ds that FJ can create' ?87/L6 ;T/;T ;T/;T D6T8:L? B$ remo"in! a## cows with -ree& :D 9, the #ine% re&ces to 2, A, A, A, A, 5, A' :n this new #ine%, there is a conti!os -#oc o cows with the same -ree& :D (A)'
Doorsmeer
Pada suatu tempat cuci motor yang sederhana :)) pelanggan harus dengan sabar menunggu karena motor hanya dapat dicuci satu per satu Motor yang kotor harus dicuci lebih lama dari motor yang lebih bersih. Pemilik Doorsmeer pusing untuk mengatur motor mana yg harus dicuci terlebih dahulu agar total waktu yang ditunggu tiap pelanggan seminimal mungkin. Sebagai contoh terdapat 3 motor untuk dicuci dengan lama waktu cuci 10 !0 30 menit. penyusunan 10 !0 30 maka pelanggan 1 menunggu 10 menit pelanggan " menunggu 10#!0 pelanggan 3 menunggu 10#!0#30. maka totalnya adalah $10)#$10#!0)#$10#!0#30) % 1!0 menit. &ika penyusunan !0 10 30 maka total lama waktu adalah 1'0 menit. (antulah pemiliknya untuk menghitung total lama waktu yang ditunggu tiap pelanggan seminimal mungkin. Input (aris pertama berisi $1 *% *% "0000). (aris "..#1 berisi lama pencucian motor ke i $tidak lebih dari 300). Output +otal lama waktu yang ditunggu tiap pelanggan seminimal mungkin. Sample Input ! 10 !0 "0 10
Sample Output 1,0 Problem setter: tiok-cek
6m%t$ ?ta##s [Brian Dean, 2019] Farmer John+s new -arn consists o a h!e circ#e o N sta##s (2 <= N <= 9,000,000), nm-ere& 0''N>1, with sta## N>1 -ein! a&acent to sta## 0' 8t the en& o each &a$, FJ+s cows arri"e -ac at the -arn one -$ one, each with a %reerre& sta## the$ wo#& #ie to occ%$' Iowe"er, i a cow+s %reerre& sta## is a#rea&$ occ%ie& -$ another cow, she scans orwar& se3entia##$ rom this sta## nti# she in&s the irst nocc%ie& sta##, which she then c#aims' : she scans %ast sta## N>1, she contines scannin! rom sta## 0' Oi"en the %reerre& sta## o each cow, %#ease &etermine the sma##est in&e o a sta## that remains nocc%ie& ater a## the cows ha"e retrne& to the -arn' Notice that the answer to this 3estion &oes not &e%en& on the or&er in which the cows retrn to the -arn' :n or&er to a"oi& isses with rea&in! h!e amonts o in%t, the in%t to this %ro-#em is s%eciie& in a concise ormat sin! E #ines (1 <= E <= 10,000) each o the orm P Q 8 B ne o these #ines s%eciies the %reerre& sta## or PQ tota# cows P cows %reer each o the sta##s (1) '' (Q), where (i) = (8i B) mo& N' The "a#es o 8 an& B #ie in the ran!e 0'''1,000,000,000' Do not or!et the stan&ar& memor$ #imit o @7B or a## %ro-#ems' /4BL67 N876 em%t$ :N/;T F478T Line 1 Two s%ace>se%arate& inte!ers N an& E' Lines 2''1E a-o"e' wi## -e se"era#
6ach #ine contains inte!ers P Q 8 B, inter%rete& as The tota# nm-er o cows s%eciie& -$ a## these #ines at most N>1' ows can -e a&&e& to the same sta## -$ o these #ines'
?87/L6 :N/;T 10 9 9 2 2 2 1 0 1 1 1 1 A :N/;T D6T8:L? There are 10 sta##s in the -arn, nm-ere& 0''C' The secon& #ine o in%t states that 9 cows %reer sta## (21) mo& 10 = @, an& 9 cows %reer sta## (22) mo& 10 = ' The thir& #ine states that 2 cows %reer sta## (011) mo& 10 = 1' Line or s%eciies that 1 cow %reers sta## (11A) mo& 10 = (so a tota# o cows %reer this sta##)' ;T/;T F478T
Line 1 The minimm in&e o an nocc%ie& sta##' ?87/L6 ;T/;T 5 ;T/;T D6T8:L? 8## sta##s wi## en& % occ%ie& ece%t sta## 5'
Islands [Brian Dean, 2012]
Problem 3: heneBer it rains, Carmer Dohn8s $ied a'ays ends up $ooding! o'eBer, sin%e the $ied isn8t per$e%ty eBe, it $is up 'ith 'ater in a non-uni$orm $ashion, eaBing a number o$ "isands" separated by epanses o$ 'ater! CD8s $ied is des%ribed as a one-dimensiona ands%ape spe%i$ied by N 6* <= N <= *)),)))7 %onse%utiBe height Baues 6*7!!!6n7! Assuming that the ands%ape is surrounded by ta $en%es o$ e$$e%tiBey in$inite height, %onsider 'hat happens during a rainstorm( the o'est regions are %oBered by 'ater $irst, giBing a number o$ dis#oint "isands", 'hi%h eBentuay 'i a be %oBered up as the 'ater %ontinues to rise! The instant the 'ater eBe be%ome e3ua to the height o$ a pie%e o$ and, that pie%e o$ and is %onsidered to be under'ater!
An eampe is sho'n aboBe( on the e$t, 'e haBe added #ust oBer * unit o$ 'ater, 'hi%h eaBes . isands 6the maimum 'e 'i eBer see7! Later on, a$ter adding a tota o$ 1 units o$ 'ater, 'e rea%h the $igure on the right 'ith ony t'o isands eposed! &ease %ompute the maimum number o$ isands 'e 'i eBer see at a singe point in time during the storm, as the 'ater rises a the 'ay to the point 'here the entire $ied is under'ater! /4BL67 N876 is#an&s :N/;T F478T Line 1 The inte!er N' Lines 2''1N Line i1 contains the hei!ht I(i)' 1,000,000,000) ?87/L6 :N/;T (i#e is#an&s'in) 9 5 2 9 1
(1 <= I(i) <=
2 9 :N/;T D6T8:L? The sam%#e in%t matches the i!re a-o"e' ;T/;T F478T Line 1 8 sin!#e inte!er !i"in! the maimm nm-er o is#an&s that a%%ear at an$ one %oint in time o"er the corse o the rainstorm' ?87/L6 ;T/;T (i#e is#an&s'ot)
#EA2A &ada pea#aran matematika kai ini, &eter bea#ar menyederhanakan pe%ahan! Fiberikan sebuah pe%ahan, &eter diminta untuk menyederhanakan pe%ahan ke bentuk paing sederhana! &eter merasa soa ini tidakah semudah yang dibayangkan, karena mungkin sa#a gurunya men#ebaknya meaui soa-soa yang unik! Spesifikasi masukan
:asukan terdiri dari beberapa kasus, input berhenti ketika End O$ Cie! Tiap kasus terdiri dari satu baris yaitu berisi dua buah integer dipisah 88! Fi#amin bah'a masukan adaah Baid 6tidak akan menimbukan error7! Spesifikasi keluaran
>euaran berupa beberapa baris berupa pe%ahan paing sederhana! N;( &astikan program anda bisa ber#aan pada kasus-kasus ekstrimH !nt!" masukan
2 */0 02 44*)) //// !nt!" keluaran
. * . 44*)) *
*)/! A ay To Cind &rimes Time Limit( *!) 5e%onds :emory Limit( 0//0>
es-ripti!n
GiBen a integer p I *, i$ p %an be deBided ony by * and itse$, 'e say that p is a prime number! Cor eampe, * %an ony be deBided by * and *, so * is a prime numberJ * %an be deBided by si numbers( *, , , ., 0, *, so * is not a prime number! The smaest ten prime number is , , /, 1, **, *, *1, *4, , 4! Eratosthenes 'as a Greek mathemati%ian, astronomer, and geographer! e inBented a method $or $inding prime numbers that is sti used today! This method is %aed Eratosthenes85ieBe! A sieBe has hoes in it and is used to $iter out the #ui%e! Eratosthenes8s sieBe $iters out numbers to $ind the prime numbers! Eratosthenes8s sieBe %an be used as $oo's to $ind a prime numbers smaer than or e3ua to a giBen number n( 5tep* ( &ut a integers bet'een and n 6in%ude and n7 on Eratosthenes8s sieBe! 5tep ( 5ee%t the smaest number on the sieBe, suppose it is m, then m must be a prime! 5tep ( Citer out a the integers 'hi%h %an be deBided by m $rom Eratosthenes8s sieBe! 5tep. ( K$ m @ m <= n, go to 5tep ! 5tep/ ( Kntegers remains on the sieBe are a prime numbers! Cor eampe, i$ 'e 'ant to $ind a primes bet'een and ) using Eratosthenes8s sieBe,&ut a integers bet'een and ) on Eratosthenes8s sieBe! ?ie"e 2, 9, , 5, @, A, , C, 10, 11, 12, 19, 1, 15, 1@, 1A, 1, 1C, 20 /rime -in ?e##ect the sma##est nm-er, it+s 2, so it is a %rime' Then i#ter ot a## inte!ers can -e &e"i&e& -$ 2 ?ie"e 9, 5, A, C, 11, 19, 15, 1A, 1C /rime -in 2 ?e##ect the sma##est nm-er, it+s 9, so it is a#so a %rime' Then i#ter ot a## inte!ers can -e &e"i&e& -$ 2 ?ie"e 5, A, 11, 19, 1A, 1C /rime -in 2, 9
?e##ect the sma##est nm-er, it+s 5, so it is a#so a %rime' Then i#ter ot a## inte!ers can -e &e"i&e& -$ 5 ?ie"e A, 11, 19, 1A, 1C /rime -in 2, 9, 5 Becase 5 5 = 25 R 20, so a## nm-ers remains on 6ratosthenes+s sie"e are %rime, %t a## o them into %rime -in ?ie"e /rime -in 2, 9, 5, A, 11, 19, 1A, 1C
No' the task is, giBen a number k, output the k-th smaest prime number! 6You may use any 'ay you 'ant to soBe this probem as it is %orre%t7 5nput
The $irst ine is an integer n, the number o$ test %ases, n %ases $oo's! Cor Ea%h test %ase has an singe integer k 6k I *7! utput
A singe integer per ine, the k-th prime number! Kt is guaranted that the %orre%t ans'er is smaer than *)))))! Sample 5nput 1 10 100 1000
Sample utput 2 2C 51 AC1C
2int
K$ you 'ant to use an arge arrays, &ease de$ine them as goba Bariabes! Cor eampe, i$ K 'ant to use an array named arrM( Sinc#&e ''' ''' ''' int arr[1000000]*
int main () '''''' M
4nnin! La%s [Brian Dean, 2012] Bore& with horse racin!, Farmer John &eci&es to in"esti!ate the easi-i#it$ o cow racin! as a s%ort' Ie sets % his N cows (1 <= N <= 100,000) to rn a race o L #a%s aron& a circ#ar trac o #en!th ' The cows a## start at the same %oint on the trac an& rn at &ierent s%ee&s, with the race en&in! when the astest cow has rn the tota# &istance o L' FJ notices se"era# occrrences o one cow o"ertain! another, an& won&ers how man$ times this sort o crossin! e"ent ha%%ens &rin! the entire race' 7ore s%eciica##$, a crossin! e"ent is &eine& -$ a %air o cows (,$) an& a time t (#ess than or e3a# to the en&in! time o the race), where cow crosses in ront o cow $ at time t' /#ease he#% FJ cont the tota# nm-er o crossin! e"ents &rin! the entire race' /4BL67 N876 rnnin! :N/;T F478T Line 1 Three s%ace>se%arate& inte!ers N, L, an& ' 25,000)'
(1 <= L, <=
Lines 2''1N Line i1 contains the s%ee& o cow i, an inte!er in the ran!e 1''1,000,000' ?87/L6 :N/;T 2 100 20 100 A0 1 :N/;T D6T8:L? There are cows rnnin! 2 #a%s on a circ#ar trac o #en!th 100' s%ee&s o the cows are 20, 100, A0, an& 1'
The
;T/;T F478T Line 1 The tota# nm-er o crossin! e"ents &rin! the entire race' ?87/L6 ;T/;T ;T/;T D6T8:L? The race #asts 2 nits o time, since this is the time it taes the astest cow (cow 2) to inish' Githin that time, there are crossin! e"ents cow 2 o"ertaes cows 1 an& , an& cow 9 o"ertaes cows 1 an& '
Silap &eter sedang bea#ar angka, gurunya FaBid sedang menga#arkan dia dengan %ara yang unik! &ak FaBid menuiskan sebanyak n-* angka 6semua angka berbeda muai dari *!!n dengan a%ak7, au &eter disuruh untuk men%ari angka yang hiang dari kumpuan angka *!!n! &eter muai bingung %ara men%arinya au dia meminta bantuan kaian untuk membuatkan program pen%ari angka hiang! Spesifikasi masukan
;aris pertama berisi integer 6* <= n <= ))))7 menyatakan #umah biangan! n-* baris berikutnya merupakan angka-angka sesuai deskripsi diatas! Spesifikasi keluaran
Angka yang hiang dari masukan! !nt!" masukan
@ 2 9 5 1 @ !nt!" keluaran
#en$elasan
Dika masukan diurutkan, maka didapat *, , , /, 0 angka yang hiang pada kumpuan *!!0 adaah .
Tied Down [Brian Dean, 2012] As 'e a kno', ;essie the %o' ikes nothing more than %ausing mis%hie$ on the $arm! To keep her $rom %ausing too mu%h troube, Carmer Dohn de%ides to tie ;essie do'n to a $en%e 'ith a ong rope! hen Bie'ed $rom aboBe, the $en%e %onsists o$ N posts 6* <= N <= *)7 that are arranged aong Berti%a ine, 'ith ;essie8s position 6b, by7 o%ated to the right o$ this Berti%a ine! The rope CD uses to tie do'n ;essie is des%ribed by a se3uen%e o$ : ine segments 6 <= : <= *),)))7, 'here the $irst segment starts at ;essie8s position and the ast ends at ;essie8s position! No $en%e post ies on any o$ these ine segments! o'eBer, ine segments may %ross, and mutipe ine segments may oBerap at their endpoints! ere is an eampe o$ the s%ene, Bie'ed $rom aboBe(
To hep ;essie es%ape, the rest o$ the %o's haBe stoen a sa' $rom the barn! &ease determine the minimum number o$ $en%e posts they must %ut through and remoBe in order $or ;essie to be abe to pu $ree 6meaning she %an run a'ay to the right 'ithout the rope %at%hing on any o$ the $en%e posts7! A 6,y7 %oordinates in the input 6$en%e posts, ;essie, and ine segment endpoints7 ie in the range )!!*),)))! A $en%e posts haBe the same %oordinate, and b is arger than this Baue! /4BL67 N876 tie& :N/;T F478T Line 1 For s%ace>se%arate& inte!ers N, 7, -, -$' Lines 2''1N Line i1 contains the s%ace>se%arate& an& $ coor&inates o ence %ost i' Lines 2N''2N7 6ach o these 71 #ines contains, in se3ence, the s%ace>se%arate& an& $ coor&inates o a %oint a#on! the ro%e' The irst an& #ast %oints are a#wa$s the same as Bessie+s
#ocation (-, -$)' ?87/L6 :N/;T 2 2 2 @ 2 1 2 9 1 5 9 0 9 @
10 @ 1 9 1 1 1 0 1 9 0 1 2 1
:N/;T D6T8:L? There are two %osts at (2,9) an& (2,1)' Bessie is at (@,1)' The ro%e !oes rom (@,1) to (2,) to (1,1), an& so on, en&in! ina##$ at (@,1)' The sha%e o the ro%e is the same as in the i!re a-o"e' ;T/;T F478T Line 1 The minimm nm-er o %osts that nee& to -e remo"e& in or&er or Bessie to esca%e -$ rnnin! to the ri!ht' ?87/L6 ;T/;T 1 ;T/;T D6T8:L? 4emo"in! either %ost 1 or %ost 2 wi## a##ow Bessie to esca%e'
Unlocking Blocks (Silver) [Brian Dean, 2012] A itte-kno'n $a%t about %o's is that they oBe pu++esH Cor ;essie8s birthday, Carmer Dohn giBes her an interesting me%hani%a pu++e $or her to soBe! The pu++e %onsists o$ three soid ob#e%ts, ea%h o$ 'hi%h is buit $rom ** unit s3uares gued together! Ea%h o$ these ob#e%ts is a "%onne%ted" shape, in the sense that you %an get $rom one s3uare on the ob#e%t to any other s3uare on the ob#e%t by stepping north, south, east, or 'est, through s3uares on the ob#e%t! An ob#e%t %an be moBed by repeatedy siding it either north, south, east, or 'est one unit! The goa o$ the pu++e is to moBe the ob#e%ts so that they are separated -- 'here their bounding boes no onger share any positiBe oBerap 'ith ea%h-other! GiBen the shapes and o%ations o$ the three ob#e%ts, your task is to hep ;essie de%ide 'hat is the minimum number o$ indiBidua sides re3uired to separate the ob#e%ts!
/4BL67 N876 n#oc :N/;T F478T Line 1 Three s%ace>se%arate& inte!ers N1, N2, an& N9, &escri-in! res%ecti"e#$ the nm-er o nit s3ares main! % o-ects 1, 2, an& 9' Lines 2''1N1 6ach o these #ines &escri-es the (,$) #ocation o the soth>west corner o sin!#e s3are that is %art o o-ect 1' 8## coor&inates #ie in the ran!e 0''C' Lines 2N1''1N1N2 6ach o these #ines &escri-es the (,$) #ocation o the soth>west corner o sin!#e s3are that is %art o o-ect 2' 8## coor&inates #ie in the ran!e 0''C' Lines 2N1N2''1N1N2N9 6ach o these #ines &escri-es the (,$) #ocation o the soth>west corner o sin!#e s3are that is %art o o-ect 9' 8## coor&inates #ie in the ran!e 0''C' ?87/L6 :N/;T 12 9 5 0 0 1 0 2 0 9 0
9 0 0 0 0 1 2 9 2 2 1 2 9
1 1 2 9 1 2 2 9 9 9 2
:N/;T D6T8:L? -ect 1 is ma&e rom 12 s3ares, o-ect 2 is ma&e rom 9 s3ares, an& o-ect 9 is ma&e rom 5 s3ares' The sha%es o the o-ects are those in the i!re a-o"e' ;T/;T F478T Line 1 The minimm nm-er o mo"es necessar$ to se%arate the three o-ects, or >1 i the o-ects cannot -e se%arate&' ?87/L6 ;T/;T 5 ;T/;T D6T8:L? : we s#i&e o-ect 9 to the east -$ one %osition, then s#i&e o-ect 2 north -$ one %osition, then s#i&e o-ect 1 west -$ three %ositions, then the -on&in! -oes o the three o-ects wi## no #on!er share an$ o"er#a% in common'