question
stringlengths 58
4.29k
| label
class label 3
classes |
---|---|
you give array consist n integer in jump position position a_i 1 le a_i position a_i a_i le nFor position 1 n want know minimum number move require reach position j a_j opposite parity a_i ie a_i odd a_j vice versa | 0array
|
you play strategic video game yeah run good problem legend in game control large army goal conquer n castle opponentlets describe game process detail Initially control army k warrior your enemy control n castle conquer ith castle need a_i warrior good game do not lose warrior take castle army stay fight after control castle recruit new warrior army formally capture ith castle b_i warrior join army furthermore capture castle later defend leave warrior castle castle consider defend each castle importance parameter c_i total score sum importance value defend castle there way defend castle currently castle leave warrior defend castle m oneway portal connect castle each portal characterised number castle u v portal hold u v a portal follow currently castle u send warrior defend castle v obviously order warrior defend castle leave armyyou capture castle fix order capture second after capture castle capture castle 1 recruit new warrior castle leave warrior defend castle use number portal lead castle castle have small number as soon capture castle action castle will not available youIf moment game do not warrior capture castle lose your goal maximize sum importance value defend castle note hire new warrior castle defend use portal lead capture score calculate afterwardsCan determine optimal strategy capturing defend castle | 2string
|
you give n integer a_1 a_2 dot a_n 1le le n hold inle a_ile i1find nonempty subset integer sum equal 0 it show subset exist give constraint if possible subset zerosum find | 1graph
|
this problem interactiveWe hide array n pairwise different number mean number equal you information array new device order Amazon this device answer query follow form response position k different element array return position value mth ascend orderunfortunately instruction device lose delivery however remember k do not remember m your task find m query device you ask n queriesnote array number m fix start interaction do not depend query in word interactor adaptivenote do not minimize number query do not need guess array you guess m | 1graph
|
two player decide play interesting card gameThere deck n card value 1 n the value card pairwise different mean different card equal value at begin game deck completely distribute player player card the game go follow turn player choose card whichever want put table player do not card choose after card reveal player value card large take card hand note card different value card strictly large every card play time the player lose do not cardsfor example suppose n 5 player card value 2 3 second player card value 1 4 5 then possible flow game isthe player choose card 3 the second player choose card 1 as 31 player get card now player card 1 2 3 second player card 4 5the player choose card 3 the second player choose card 4 as 34 second player get card now player card 1 2 the second player card 3 4 5the player choose card 1 the second player choose card 3 as 13 second player get card now player card 2 the second player card 1 3 4 5the player choose card 2 the second player choose card 4 as 24 second player get card now player card lose therefore second player winsWho win player play optimally it show player win strategy | 2string
|
you give positive integer m integer sequence aa_1 a_2 ldot a_n bb_1 b_2 ldot b_n both sequence length nPermutation sequence n different positive integer 1 n for example sequence permutation 1 12 21 6734125 these 0 11 23you need find nonnegative integer x increase element a_i x modulo m ie want change a_i a_i x bmod m possible rearrange element equal b need find small possible xIn word need find small nonnegative integer x possible find permutation pp_1 p_2 ldot p_n 1 leq leq n a_i x bmod m b_p_i y bmod m remainder division y mFor example m3 0 0 2 1 b 2 0 1 1 choose x1 equal 1 1 0 2 rearrange equal 2 0 1 1 equal b | 1graph
|
you give permutation p_1 p_2 ldot p_nIn swap adjacent valuesyou want perform minimum number move end exist subsegment 12ldots k word end integer 1 leq leq nk1 p_i 1 p_i1 2 ldot p_ik1klet fk minimum number move need subsegment value 12ldotsk appear permutationyou need find f1 f2 ldot fn | 1graph
|
BerPhone x ready release n application preinstalle phone a category application characterize genre theme application like game business education the category give integer 1 n inclusive ith application category c_i you choose m number screen s size screen you need fit n icon application icon represent application meeting follow requirement on screen icon belong application category different screen contain icon application category each screen completely fill icon number icon screen equal tos fill icon number icon equal s1 your task find minimal possible number screen m | 2string
|
very soon new cell phone service provider BerLine begin work BerlandThe start customer service plan main street capital there nbase station instal they locate main street order the1st thenth leave right currently base station turn they turn base station day accord permutation p p_1 p_2 dot p_n 1 le p_i le n p_i index base station turn ith day thus n day turn base stationsEach base station characterize operating frequency f_i integer 1 24 inclusivethere important requirement operating frequency base station consider arbitrary moment time for phone owner consider base station turn access area phone set base station operate frequency unique frequency station since power phone position know advance mean nonempty subsegment turn base station operate frequency unique station subsegmentfor example let look case n 7 n station turn frequency equal f 1 2 1 3 1 2 1 consider subsegment base station base station unique frequency subsegment however f 1 2 1 2 3 2 1 unique frequency segment 1 2 1 2 index 1 index 4 inclusiveYour task assign frequency 1 24 n base station way frequency requirement meet moment remember base station turn order give permutation p | 1graph
|
Daisy senior software engineer RainyDay LLC she implement new feature product feature make product work second make product fast make product correct the company encourage test new feature Daisy appoint intern Demid write test new featuresinterestingly feature pass test Demids development server index 1 fail test serversAfter Demid complete task Daisy appoint deploy feature nserver company for feature f server s Daisy tell want feature f deploy server s if wants deploy feature f fail test server s if want deploy deploy thereyour company important instrument deployment new feature server Continuous Deployment CD Continuous Testing CT CD establish pair server form direct graph CT set set serversif cd configure server s_1 server s_2 time s_1 receive new feature f system start follow deployment process f s_2 if feature f deploy server s_2 Otherwise CT set server s_1 server s_1 deploy feature f server s_2 testing Otherwise server s_1 run test feature f if test fail server s_1 if test pass server s_1 deploy feature f server s_2 you configure cdct system Demid deploy feature development server your cdct system deploy feature exactly set server Daisy wantsyour company lot computing resource establish cd server 264 time | 2string
|
Balph learning play game call Buma in game give row color ball he choose color new ball place insert ball leave ball right ballsWhen ball insert follow happen repeatedly segment ball color long result previous action length 3 ball segment eliminate consider example row ball AAABBBWWBB suppose Balph choose ball color W place insert sixth ball ie leave Ws after Balph insert ball ball color W eliminate segment long length 3 row AAABBBBB the ball color B eliminate segment ball color B long length 5 thus row AAA However ball eliminate elongated segmentHelp Balph count number possible way choose color new ball place insert lead elimination ball | 1graph
|
there direct graph n vertex number 1 n vertex n outgoing arcs red blue at point time exactly arcs active vertex initially blue arc active token locate vertex 1 in second vertex token switch active arcs inactive arc active vice versa then token move active arc when token reach vertex n stop it guarantee n reachable arc vertexyou give q query each query contain state graph pair v s follow form v vertex token currently locate s string consist n 1 character the ith character correspond color active edge lead ith vertex character r red arc active character b for query determine give state reachable initial state time configuration appear note operation change active arc traverse atomic state consider reach appear change active arc traverse | 1graph
|
Bob competitive programmer he want red need strict training regime he go annual meeting grandmaster ask n effort need reach redOh I spend x_i hour solve problem say ith Bob want train math skill answer write number minutes 60 cdot x_i thank grandmaster go home Bob write number lead zeroes example grandmaster answer spend 2 hour Bob write 000120 instead 120alice want tease Bob take number Bob write follow independently rearrange digit write random number this way Alice generate n number denote y_1 y_nfor number help Bob determine y_i permutation number divisible 60 possibly lead zero | 1graph
|
a string call beautiful consecutive character equal for example ababcb abab beautiful string aaaaaa abaa bb notAhcl want construct beautiful string he string s consist character b c Ahcl need replace character character b c result string beautiful please help himmore formally replace character condition s_i neq s_i1 satisfy 1 leq leq s 1 s length string s | 2string
|
a football league recently begin beautiful land there n team participate league Lets enumerate integer 1 nThere play exactly fracnn12 match team play team exactly in match winner loser drawafter match play organizer count number beautiful triple let triple team a b c beautiful team a win team b team b win team C team C win team a we look triple different team order team triple importantthe beauty league number beautiful triplesAt moment m match play result knownwhat maximum beauty league play remain match also find possible result remain fracnn12 m match league maximum beauty | 2string
|
an electrical grid Berland palace consist 2 grid main reserve Wires palace expensive material sell good ideaeach grid main reserve head node number 1 every node get electricity head node each node reach head node unique path also grid exactly n node spread electricity furtherIn word grid root direct tree n leave root node number 1 each tree independent enumeration node grid connect node gridAlso palace n electrical device each device connect node main grid node reserve grid Devices connect node electricity spread node tree leave each grid leaf connect exactly device in example main grid contain 6 node tree reserve grid contain 4 node low tree there 3 device number color blue it guarantee grid grid n device show way like picture main grid tree wire direct reserve grid low tree wire direct device horizontal row grid number 1 n leave right wire node intersect Formally tree exist depthfirst search node number 1 visit leave order connection device 1 2 dot n firstly node connected device 1 node connect device 2 etcbusinessman want sell remove maximal wire device power grid main reserve in word device exist path head node main grid reserve grid contain node grid | 1graph
|
you give integer b you perform number operation possibly zerodure operation choose positive integer x set x b b 2x 2x b b x Note choose different value x different operationsIs possible b equal 0 simultaneouslyyour program answer t independent test case | 1graph
|
you play computer game in game lead party m hero clear dungeon n monster each monster characterize power a_i each hero characterize power p_i endurance s_iThe heroe clear dungeon day day in begin day choose hero exactly go enter dungeon daywhen hero enters dungeon challenge monster defeat previous day hero defeat k monster hero fight monster k 1 when hero fight monster possible outcomes monster power strictly great hero power hero retreat dungeon the current day end monster defeat after defeat monster hero continue fight monster leave dungeon he leave dungeon defeat number monster equal endurance day ith hero defeat s_i monster day monster defeat fight monster when hero leave dungeon current day endsyour goal defeat monster what minimum number day need achieve goal each day use exactly hero possible hero do not fight monster each hero arbitrary number time | 1graph
|
let array t dominate value v situationat array t 2 element now let calculate number occurrence number num t define occnum then t dominate v occv occv number v for example array 1 2 3 4 5 2 11 11 3 2 3 2 3 dominate 2 11 3 respectevitely array 3 1 2 3 3 2 2 1 notsmall remark array dominate number specify number array dominate notyou give array a_1 a_2 dot a_n calculate shortest dominate subarray subarraysthe subarray contiguous array ie array a_i a_i 1 dot a_j 1 le le j le n | 1graph
|
this interactive problemkhanh n point cartesian plane denote a_1 a_2 ldot a_n all point coordinate integer 109 109 inclusive no point collinear he say point vertex convex polygon word exist permutation p_1 p_2 ldot p_n integer 1 n polygon a_p_1 a_p_2 ldot a_p_n convex vertex list counterclockwise orderKhanh give number n hide coordinate point your task guess permutation ask multiple query in query Khanh 4 integer t j k t 1 t 2 j k distinct index 1 n inclusive in response Khanh tell t 1 area triangle a_ia_ja_k multiply 2 t 2 sign cross product vector overrightarrowa_ia_j overrightarrowa_ia_k Recall cross product vector overrightarrowa x_a y_a vector overrightarrowb x_b y_b integer x_a cdot y_b x_b cdot y_a the sign number 1 positive 1 it prove cross product obtain query 0you ask 3 cdot n queriesplease note Khanh fix coordinate point change answer query you need guess coordinate in permutation a_p_1a_p_2ldot a_p_n p_1 equal 1 index vertex list counterclockwise order | 1graph
|
Talia buy abandon house outskirt Jakarta the house nice long yard represent onedimensional grid contain 1 time n cell to beautify house Talia going build terrace yard tiling cell each cell yard contain soil represent character rock represent character 50 cell contain rocksbee superstitious person Talia want tile terrace mystical tile power repel ghost there type mystical tile type1 cover 1 time 1 cell place soil cell type2 cover 1 time 2 cell place consecutive soil cell type3 cover 1 time 3 cell place consecutive soilrocksoil cell each tile type1 Type2 Type3 power repel G_1 G_2 G_3 ghost day respectively there mystical rule follow power effective there overlap tile ie cell cover tile there k tile type1 limitation tile type2 Type3 Talia scare ghost terrace tile mystical tile able repel ghost possible help Talia find maximum number ghost repel day terrace Note Talia need tile cell yard long number ghost repel terrace maximum | 0array
|
pathfinde task find route point it appear problem for example GPS navigation software driver query suggest route robot motion planning find valid sequence movement task simple maze solver find valid path point point this problem relate solving mazethe maze consider problem form matrix integer a n time N the value cell generate give array r c n integer specifically value ith row jth column cell ij equal R_i C_j Note index problem 1 NA path maze define sequence cell r_1c_1 r_2c_2 dot r_kc_k r_i r_i1 c_i c_i1 1 1 le k in word adjacent cell differ 1 row 1 column an path maze define path cell path contain numbersgiven tuple langle r_ac_ar_bc_b rangle query task determine exist path cell r_ac_a cell r_bc_b to simplify problem guarantee cell r_ac_a cell r_bc_b contain numbersfor example let N 5 r 6 2 7 8 3 c 3 4 8 5 1 the following figure depict matrix a 5 time 5 generate give array r c let consider query langle 2 2 1 3 rangle there path cell 22 cell 13 eg 22 23 13 of course 22 12 13 valid path langle 4 2 4 3 rangle there path cell 42 cell 43 42 43 langle 5 1 3 4 rangle there path cell 51 cell 34 Observe neighboring cell 51 cell 52 cell 41 contain odd number 7 11 respectively path originate cell 51 | 2string
|
you head large enterprise n people work n odd ie n divisible 2you distribute salary employee initially s dollar ith employee salary l_i r_i dollar you distribute salary way median salary maximum possibleTo find median sequence odd length sort element middle position sort for example median sequence 5 1 10 17 6 6 median sequence 1 2 1 1 it guarantee money pay minimum salary ie l_1 l_2 dot l_n le sNote do not spend s dollar salariesyou answer t test case | 1graph
|
recently Polycarp notice button keyboard malfunction for simplicity assume Polycarps keyboard contain 26 button letter latin alphabet each button work fine malfunctioning to check button need replacement Polycarp press button sequence string s appear screen when Polycarp press button character c follow event happen button work correctly character c appear end stre Polycarp type button malfunction character c appear end string for example suppose button correspond character c work correctly button corresponding b malfunctioning if Polycarp press button order b c b string typing change follow rightarrow abb rightarrow abba rightarrow abbac rightarrow abbaca rightarrow abbacabb rightarrow abbacabbayou give string s appear screen Polycarp press button help Polycarp determine button work correctly sure string appear screen button malfunctioningyou assume button do not start malfunction Polycarp type stre button work correctly process malfunction process | 1graph
|
a group student recently admit Faculty Computer Sciences Berland State University now programming teacher want divide subgroup practice sessionsThe teacher know lot programmer argue language well the teacher do not want hear argument subgroup want divide student subgroup pair student belong subgroup want argueTo perform division teacher ask student programming language like there student answer enjoy Assembler b student state favourite language Basic c remain student claim C good programming language large argument Assembler fan C fansnow know Assembler programmer C programmer start argument minute teacher want divide student subgroup student belong exactly subgroup subgroup contain Assembler fan C fan since teach lot student difficult teacher want size large subgroup minimum possibleplease help teacher calculate minimum possible size large subgroup | 2string
|
there n lecture m seminar conduct today Faculty Approximate Sciences the ith lecture start a_i end b_i formally time lecture span interval a_i b_i right bind exclusive the jth seminar start p_j end q_j similarly time seminar spans interval p_j q_j right bind exclusivethere x HDprojectors number 1 x y ordinary projector number x 1 x y available faculty Projectors distribute way HDprojector lecture projector ordinary HD seminar projector ordinary HD event moment time projector select event duration event projector reuse follow event start early current event finish you find distribution projector existsagain note right bind event time range inclusive event start exactly event finish projector reuse suppose instantly transport location event | 1graph
|
Eulampius create game follow rule player game human computer game last n round Initially player 0 point in jth round human gain a_j point computer gain b_j point the point gain simultaneously game end player get k point this player lose game if player k point simultaneously lose player k point n round game end tie round human push reset button if human x point computer y point button push course x k y k button push human x max0 x y point computer y max0 y x point Eg push reset button transform state x3 y5 state x0 y2 state x8 y2 state x6 y0Eulampius ask friend Polycarpus test game Polycarpus quickly reveal amount point gain human computer n round generate game store file in word push reset button influence value a_j b_j sequence b fix know advancePolycarpus want plan game he like win game push Reset button time possible your task determine minimal number push determine Polycarpus win | 1graph
|
employee JebTrains way celebrate 256th day year there n employee k team JebTrains each employee member exactly team all team number 1 k you give array number t_1 t_2 dot t_n t_i ith employee team numberjebtrain go rent single bus employee feast the bus ride a bus pick entire team entire team if team ride start new project consider unacceptable its prohibit split team member team rideIt possible rent bus capacity s such bus s people single ride the total cost rent equal s cdot r burle r number ride Note impossible rent buseshelp JebTrains calculate minimum cost rent require employee feast fulfil condition | 2string
|
you give tree consist n vertice Recall tree connect undirected graph cycle Example tree vertex number 1 n all vertex weight weight vertex v a_vrecall distance vertex tree number edge simple path themYour task find subset vertice maximum total weight weight subset sum weight vertex pair vertex distance k subset | 1graph
|
the difference easy hard version maximum value nYou give positive integer number n you love good number want find small good number great equal nThe positive integer call good represent sum distinct power 3 ie duplicate power 3 allowedFor example 30 good number 30 33 31 1 good number 1 30 12 good number 12 32 31 2 good number can not represent sum distinct power 3 2 30 30 19 good number can not represent sum distinct power 3 example representation 19 32 32 30 32 31 31 31 30 invalid 20 good number can not represent sum distinct power 3 example representation 20 32 32 30 30 invalid Note exist representation 19 20 sum power 3 consist distinct power 3for give positive integer n find small m n le m m good numberyou answer q independent query | 2string
|
the difference easy hard version constraintsthere n kid read unique book at end day ith kid book p_ith kid case p_i kid book it guarantee value p_i distinct integer 1 n ie p permutation the sequence p do not change day day fixedfor example n6 p4 6 1 3 5 2 end day book 1st kid belong 4th kid 2nd kid belong 6th kid at end second day book 1st kid belong 3th kid 2nd kid belong 2th kid onyour task determine number day book ith child return time 1 nConsider follow example p 5 1 2 4 3 the book 1st kid pass follow kid 1st day belong 5th kid 2nd day belong 3rd kid 3rd day belong 2nd kid 4th day belong 1st kid so fourth day book kid return owner the book fourth kid return time exactly dayyou answer q independent query | 1graph
|
you coach group consist n student the ith student programming skill a_i all student distinct programming skill you want divide team way no student j a_i a_j 1 belong team ie skill pair student team difference strictly great 1 number team minimum possible you answer q independent query | 1graph
|
Shichikuji new resident deity South Black Snail Temple her job followsthere n new city locate Prefecture X city number 1 n City locate x_i km North shrine y_i km East shrine it possible x_i y_i x_j y_j ne jShichikuji provide electricity city building power station city make connection city electricity so City electricity power station connect City electricity direct connection chain connection build power station City cost c_i yen make connection City City j cost k_i k_j yen km wire connection however wire cardinal direction North South East West Wires cross each wire endpoint city if City City j connect wire wire short path City City j thus length wire City City j connect x_i x_j y_i y_j km Shichikuji want job spend little money possible accord is not world money however die fifth grade smart and new resident deity ask helpand provide Shichikuji follow information minimum yen need provide electricity city city power station build connection madeif multiple way choose city connection obtain construction minimum price print | 1graph
|
consider set nonnegative integer 0 1 2 dot give integer b 1 le b le 104 we paint number increase number paint 0 paint 1 2 onEach number paint white black we paint number accord follow rule 0 colored white ge color white colored white ge b b color white colored white colored white colored black in way nonnegative integer get colorsfor example a3 b5 color number order 0 white 0 black 1 black 2 white 3 black 4 white 5 white 6 black 7 white 8 white 9 note it possible infinitely nonnegative integer color black for example 10 b 10 0 10 20 30 nonnegative integer end 0 write base 10 white the integer color black it possible finitely nonnegative integer color black for example 1 b 10 nonnegative integer color black your task determine number nonnegative integer color black infiniteif infinitely nonnegative integer color black simply print line contain Infinite quote Otherwise print Finite quote | 2string
|
there n chip arrange circle number 1 n initially chip black white color then k iteration occur during iteration chip change color accord follow rule for chip chip consider chip neighbour if number white chip great number black chip chip chip white Otherwise chip black note 2 n 1 neighbouring chip number 1 1 the neighbour chip 1 n 2 the neighbour n n 1 1the follow picture describe iteration n 6 the chip 1 3 4 initially black chip 2 5 6 white after iteration 2 3 4 black 1 5 6 white your task determine color chip k iteration | 2string
|
this problem different easy version in version Ujan make 2n swap in addition k le 1000 n le 50 necessary print swap you hack problem solve but hack previous problem solve problemsAfter struggle fail time Ujan decide try clean house he decide string order firstUjan distinct string s t length n consist lowercase english character he want equal since Ujan lazy perform follow operation 2n time take position j 1 le ij le n value j equal different swap character s_i t_jUjans goal string s t equal he need minimize number perform operation sequence operation length 2n shorter suitable | 1graph
|
in Catowice city weekend cat contest hold however jury member contestant have not select there n resident n cat Catowice resident exactly cat living house the resident cat number integer 1 n ith cat living house ith residentEach Catowice resident friendship cat include live house in order conduct contest jury member need cat contestant need of course jury member know contestant for contest successful need number jury member plus number contestant equal nPlease help Catowice resident select jury contestant upcoming competition determine impossible | 1graph
|
assume k onedimensional segment s_1 s_2 dot s_k segment denote integer endpoint then build follow graph segment the graph consist k vertex edge ith jth vertexes neq j segment s_i s_j intersect exist point belong themfor example s_1 1 6 s_2 8 20 s_3 4 10 s_4 2 13 s_5 17 18 result graph follow a tree size m good possible choose m onedimensional segment graph build segment coincide treeyou give tree find good subtree maximum possible size Recall subtree connect subgraph treenote answer q independent query | 1graph
|
you password type string s length n every character string m lowercase Latin lettersSince spend lot time typing want buy new keyboardA keyboard permutation m latin letter for example m 3 possible keyboard abc acb bac bca cab cbasince type password finger need spend time move finger password character the time character s_i character s_i1 equal distance character keyboard the total time spend type password keyboard call slowness keyboardmore formaly slowness keyboard equal sumlimits_i2n pos_s_i1 pos_s_i pos_x position letter x keyboardFor example s aacabc keyboard bac total time type password pos_a pos_a pos_a pos_c pos_c pos_a pos_a pos_b pos_b pos_c 2 2 2 3 3 2 2 1 1 3 0 1 1 1 2 5before buy new keyboard want know minimum possible slowness keyboard | 1graph
|
Alice recently find cactus grow near house after month cactus appear soon block road so Alice want clear thema cactus connect undirected graph no edge graph lie simple cycle Lets sequence different node graph x_1 x_2 ldot x_k simple cycle k geq 3 pair node x_1 x_2 x_2 x_3 ldot x_k1 x_k x_k x_1 connect edge Edges x_1 x_2 x_2 x_3 ldot x_k1 x_k x_k x_1 lie simple cycleThere cactus hard destroy but Alice magic when use magic node cactus remove independently probability frac12 when node remove edge connect removedNow Alice want test magic she pick cactus n node m edge let XS S subset remove node number connect component remain graph remove node set S before use magic wants know variance random variable x node graph probability frac12 remove n event independent by definition variance equal EX EX2 EX expect value x help calculate value modulo 1097formally let M 109 7 prime number it show answer express irreducible fraction fracpq p q integer q equiv 0 pmodM output integer equal p cdot q1 bmod M in word find integer x 0 le x M x cdot q equiv p pmodM | 1graph
|
you shop keeper shop assistant small nearby shop you n good ith good cost a_i coinsYou get tired remember price product customer ask decide simplify life more precisely decide set price n good haveHowever do not want lose money want choose price way sum new price sum initial price it mean sell n good new price receive great money sell initial pricesOn hand do not want lose customer big price price choose need choose minimum oneSo need find minimum possible equal price n good sell price receive great money sell initial pricesyou answer q independent query | 0array
|
you simple undirected graph consist n vertex m edge the graph do not contain selfloop edge pair vertex the give graph disconnectedlet definitionLet v_1 v_2 nonempty subset vertex intersect Let fv_1 v_2 true condition satisfied there edge endpoint vertex set v_1 there edge endpoint vertex set v_2 for vertex x y x v_1 y v_2 edge x y Create vertex set v_1 v_2 v_3 satisfy condition all vertex set each vertex assign vertex set fv_1 v_2 fv_2 v_3 fv_3 v_1 true Is possible create vertex set if possible print matching vertex set vertex | 2string
|
your program fail this time get wrong answer test 233this easy version problem in version 1 le n le 2000 you hack problem solve lock problemsthe problem test contain n onechoicequestion each question contain k option correct the answer ith question h_i answer question h_i earn 1 point earn 0 point question the value h_1 h_2 dot h_n know problemHowever mistake program it move answer clockwise consider n answer write circle due mistake program shift cyclicallyformally mistake move answer question question bmod n 1 so move answer question 1 question 2 answer question 2 question 3 answer question n question 1we n answer answer suit there kn possible answer suit totalyoure wonder answer suit satisfy follow condition move clockwise 1 total number point new answer suit strictly large number point old you need find answer modulo 998244353For example n 5 answer suit a12345 submit a51234 mistake if correct answer suit h52234 answer suit earn 1 point answer suite earn 4 point since 4 1 answer suit a12345 count | 1graph
|
this easy version problem in version 1 le n m le 100 you hack problem solve lock problemsyou give sequence integer aa_1a_2dotsa_n length n its subsequence obtain remove zero element sequence necessarily consecutively for example sequence a11201133112011 11201133112011 112011331120 11111111 20 3320 subsequence long list 40 3333 332020 20201111 subsequence suppose additional nonnegative integer k 1 le k le n give subsequence call optimal length k sum element maximum possible subsequence length k subsequence length k satisfy previous item lexicographically minimal Recall sequence bb_1 b_2 dots b_k lexicographically small sequence cc_1 c_2 dots c_k element left differ sequence b c formally exist t 1 le t le k b_1c_1 b_2c_2 b_t1c_t1 time b_tc_t for example 10 20 20 lexicographically 10 21 1 7 99 99 lexicographically 10 21 1 10 21 0 lexicographically 10 21 1 you give sequence aa_1a_2dotsa_n m request consist number k_j pos_j 1 le k le n 1 le pos_j le k_j for query print value index pos_j optimal subsequence give sequence kk_jFor example n4 a10203020 k_j2 optimal subsequence 2030 minimum lexicographically subsequence length 2 maximum total sum item thus answer request k_j2 pos_j1 number 20 answer request k_j2 pos_j2 number 30 | 1graph
|
your math teacher give follow problemthere n segment xaxis l_1 r_1 l_2 r_2 ldot l_n r_n the segment l r include bound ie set x l le x le r the length segment l r equal r lTwo segment b c d common point intersect exist x leq x leq b c leq x leq d for example 2 5 3 10 common point 5 6 1 4 do not haveyou add segment common point give segment short possible ie minimal length the require segment degenerate point ie segment length zero the add segment give n segmentsIn word need find segment b b l_i r_i common point ba minimal | 2string
|
there n positive integer write blackboard also positive number k geq 2 choose number blackboard divisible k in operation choose integer x y erase write extra number fx y fx equal x x divisible k fx fx kIn end single number blackboard Is possible final number equal 1 if restore sequence operation | 1graph
|
Vasya fancy number long integer power Petya hand conservative like single integer p positive negative zero to combine taste invent pbinary number form 2x p x nonnegative integerfor example 9binary minus binary number 8 minus 7 1015 8209 7249 10152109the boy use pbinary number represent they face problem give positive integer n what s small number pbinary number necessarily distinct need represent n sum it possible representation impossible altogether help solve problemfor example p0 represent 7 20 21 22And p9 represent 7 number 249note negative pbinary number allow sum Notes section example | 1graph
|
let look follow process initially stack array s length l you try push array element stack order s_1 s_2 s_3 dot s_l moreover stack element stack equal current element push current element stack otherwise do not push current element stack pop element stack if process stack remain array s consider stack exterminablethere sample stack exterminable array 1 1 2 1 1 2 1 1 2 2 1 3 3 1 2 2 3 1 3 3 1 3 3 3 3 3 3 3 5 1 2 2 1 4 4 5 Lets consider change stack detail s 5 1 2 2 1 4 4 5 stack highlight push s_1 5 stack turn textbf5 push s_2 1 stack turn 5 textbf1 push s_3 2 stack turn 5 1 textbf2 push s_4 2 stack turn 5 textbf1 push s_5 1 stack turn textbf5 push s_6 4 stack turn 5 textbf4 push s_7 4 stack turn textbf5 push s_8 5 stack you give array a_1 a_2 ldot a_n you calculate number subarray stack exterminablenote answer q independent query | 2string
|
you give sequence a_1 a_2 dot a_n consist integersyou apply follow operation sequence choose integer x element equal x begin end note element direction operationfor example 2 1 3 1 1 3 2 follow sequence operation convenience denote element equal x xelement 1 1 1 2 3 3 2 1elements begin 2 3 3 2 1 1 1 1elements end 2 2 1 3 1 1 3 2element begin 1 3 1 1 3 2 2 2elements end 3 3 2 1 1 1 2 3elements begin 2 1 1 1 2 3 3 3elements end you determine minimum number operation sequence sort nondescending order nondescending order mean 2 n condition a_i1 le a_i satisfiedNote answer q independent query | 1graph
|
you give undirected graph n vertex m edge you write number vertex graph number 0 1 after write number edge equal sum number vertex incident edgeyou choose number write vertex edge 0 write edge 1 edge 2 how way two way choose number different exist vertex different number write way | 2string
|
Alice Bob play game initially stre s_1 s_2 dot s_n consist character x they alternate turn Alice move during turn player select contiguous substring consist character replace X Alice select subste length Bob select substre length b it guarantee bFor example s x 3 b 2 Alices string turn xxxx and Bobs turn stre s X Bobs string turn XXX XXX XXXWhoever unable lose you determine win play optimallyyou answer q independent query | 1graph
|
you know standard ICPC team consist exactly member the perfect team restriction a student specialization coder mathematician Shehe specialization can not timeso team consider perfect include coder mathematician consist exactly membersYou coach large university know c student coder m mathematician x specializationwhat maximum number perfect team distribute note student leave team student teamyou ask answer q independent query | 1graph
|
Mike Ann sit classroom the lesson boring decide play interesting game fortunately need play game string s number k 0 le k sAt beginning game player give substre s leave border l right border r equal k ie initially lrk then player start move accord follow rule a player choose lprime rprime lprime le l rprime ge r slprime rprime lexicographically sl r then player change l r way l lprime r rprime Ann move the player can not losesrecall substring sl r l le r string s continuous segment letter s starts position l end position r for example ehn substre s3 5 aaaehnsvz ahz notMike Ann play enthusiastically notice teacher approach surprisingly teacher do not scold instead say figure winner game start know s kUnfortunately Mike Ann keen game theory ask write program take s determine winner possible k | 1graph
|
it Bubble Cup final season farmer Johnny Bubbles harvest bubble the bubble rectangular bubblefield form N x M square parcel divide n row M column the parcel ith row jth column yield a_ij bubblesJohnny bubble available special selfdriving bubble harvester manually position beginning row column automatically harvest bubble row column once harvester reach end row column stop reposition the harvester pass parcel number time collect bubble parcel onceJohnny busy farmer available manually position harvester time day Johnny impatient want harvest bubble possible dayplease help Johnny calculate maximum number bubble collect day | 2string
|
for birthday Alice receive interesting gift friend the Light Square the Light Square game play n time N lightbulbs square board magical lightbulb bar size n times 1 magical property at start game light square board magical bar turn the goal game transform start light square board pattern pattern magical bar rotate square board the magical bar work follow it place row column the orientation magical lightbulb leave right magical property the entire bar need fully place board the light magical bar change if light magical bar light square place switch light square board switch light the magical bar infinite number time Alice hard time transform square board pattern Bob give can help transform board let know impossible if multiple solution print | 2string
|
you mighty Blackout stand upperleft 00 corner nxm matrix you right second there K transformer jump matrix follow way each transformer start jump position xy time t jump position second the xaxe grow downward yaxe grow right the order jumping position define xyxdydxdyxyd periodic before time t transformer matrixyou want arrive bottomright corner N1M1 slay transformer lose possible energy when meet transformer matrix field kill lose sum energy amount require kill transformerafter transformer kill course stop jump fall abyss leave matrix world Output minimum possible energy waste | 1graph
|
the difference easy hard version maximum value kYou give infinite sequence form 112123123412345dots consist block consecutive positive integer write the block consist number 1 1 second 1 2 1 3 dot ith block consist number 1 so 56 element sequence 11212312341234512345612345671234567812345678912345678910 Elements sequence number for example 1st element sequence 1 3rd element sequence 2 20th element sequence 5 38th element 2 56th element sequence 0your task answer q independent query in ith query give integer k_i calculate digit position k_i sequence | 1graph
|
in addition complaint lighting lot complaint insufficient radio signal covering receive Bertown city hall recently n complaint send mayor suspiciosly similar ith complaint radio fan mention signal radio station x_i y_i cover part city demand signal station receive cityOf cousre mayor Bertown currently work satisfy complaint a new radio tower instal Bertown transmit signal integer power 1 M let denote signal power f the mayor decide choose set radio station establish contract choose station to establish contract ith station follow condition meet signal power f l_i signal ith station will not cover city signal power f great r_i signal receive resident town have not establish contract ith station all information mayor realise choose station hard but consulting specialist learn station signal station interfere m pair station u_i v_i use signal frequency pair impossible establish contract station if station x y use frequency y z use frequency imply x z use frequenciesthe mayor find hard analyze situation hire help you choose signal power f set station establish contract complaint satisfy formally 1 n city establish contract station x_i station y_i choose station interfere formally 1 m city establish contract station u_i station v_i choose station condition signal power meet formally choose station condition l_i le f le r_i meet | 1graph
|
monocarp arrange n colored marble row the color ith marble a_i Monocarp like order thing want rearrange marble way marble color form contiguo segment segment color in word Monocarp want rearrange marble color j leftmost marble color j lth row rightmost marble color position r row marble l r color jTo achieve goal Monocarp follow operation number time choose neighbouring marble swap themyou calculate minimum number operation Monocarp perform rearrange marble note order segment marble have equal color matter require color marble color form exactly contiguous segment | 1graph
|
author come stre s consist n lowercase Latin lettersYou give permutation index necessary equal p q length n Recall permutation array length n contain integer 1 n exactly onceFor 1 n1 follow property hold sp_i le sp_i 1 sq_i le sq_i 1 it mean write character s order permutation index result string sort nondecrease orderyour task restore string s length n consist k distinct lowercase latin letter suit give permutationsif multiple answer print | 1graph
|
there n table bowling player rate ith player equal r_i compose maximum number team way player belong team team contain exactly ab player team contain group player rating group b player rate k time large rating player group for example n12 r1 1 2 2 2 2 2 3 3 4 6 6 a1 b2 k2 compose team rating 1 2 2 team rating 3 6 6 so maximum number team 3find maximum number team give n r_1 dot r_n b k compose respect give requirement | 0array
|
Wojtek win math competition Byteland the prize admirable great book call Card Tricks everyone Great think I finally use old dust deck card that s lie unused deskThe chapter book how Shuffle k Cards any order you want its basically list n intricate method shuffle deck k card deterministic way specifically ith recipe describe permutation p_i1 p_i2 dot P_ik integer 1 k if enumerate card deck 1 k P_ij indicate number jth card deck shufflethe day short Wojtek wants learn trick today he pick integer l r 1 le l le r le n memorize trick lth rth inclusive he sort deck k card repeatedly apply random memorize trick get bored he like math start wonder different deck stop shuffle itWojtek do not choose integer l r curious therefore define fl r number different deck memorize trick lth rth inclusive what value ofsum_l1n sum_rln fl r | 2string
|
this hard version problem in version q le 200000A sequence integer call nice element arrange block like 3 3 3 4 1 1 Formally element equal equallet define difficulty sequence minimum possible number element change nice sequence however change element value x value y change element value x y for example 3 3 1 3 2 1 2 is not allow change 1 3 second 1 2 you need leave 1 untouched change valueyou give sequence integer a_1 a_2 ldot a_n q updateseach update form x change a_i x update independent change stay futureprint difficulty initial sequence sequence update | 1graph
|
this hard version problem the difference constraintsyou give rectangular n times m matrix in choose column cyclically shift element column you perform operation time want possibly zero you perform operation column multiple timesafter cyclical shift compute row maximal value suppose ith row equal r_i what maximal possible value r_1r_2ldotsr_n | 1graph
|
you give sequence n digit d_1d_2 dot d_n you need paint digit colors digit paint color 1 color 2 write row leave right digit paint color 1 digit paint color 2 result sequence n digit nondecrease digit great equal previous digit for example sequence d914 valid color 211 paint color 1 digit paint color 2 digit but 122 valid coloring 9 concatenate 14 nondecrease sequenceit allow color Digits paint color require consecutive positionsfind valid way paint give sequence digit determine impossible | 2string
|
it holiday season Koala decorate house cool light he own n light flash periodicallyafter take quick glance Koala realize light describe parameter a_i b_i light parameter a_i b_i toggle a_i second start b_ith second in word toggle moment b_i b_i a_i b_i 2 cdot a_i onYou know light initially correspond parameter a_i b_i Koala wonder maximum number light time so need find here graphic example | 1graph
|
you give array n integersyou need find maximum value a_i a_j a_k triplet ijk j kHere denote bitwise and operation denote bitwise or operation | 1graph
|
Cengiz recently learn Fibonacci number study different algorithm find after get bored reading come new type number name XORinacci number he define follow f0 f1 b fn fn1 oplus fn2 n 1 oplus denote bitwise XOR operation you give integer b n calculate fnyou answer t independent test case | 2string
|
you give array consist 500000 integer number 1 500000 Initially element zeroYou process type query array 1 x y increase a_x y 2 x y compute sumlimits_i Rx y a_i Rx y set integer 1 500000 remainder y modulo x can process query | 1graph
|
you give matrix a b each matrix contain exactly n row m column each element a 0 1 element b initially 0you perform operation matrix b during operation choose submatrix b have size 2 time 2 replace element choose submatrix 1 in word choose integer x y 1 le x n 1 le y m set b_x y b_x y 1 b_x 1 y b_x 1 y 1 1your goal matrix b equal matrix a two matrix A b equal element matrix a equal corresponding element matrix bi possible matrix equal if come sequence operation make b equal a note do not minimize number operation | 2string
|
you give n number a_1 a_2 dot a_n with cost coin perform follow operationchoose number add subtract 1 itin particular apply operation number timesWe want product number equal 1 word want a_1 cdot a_2 dot cdot a_n 1 for example n 3 number 1 3 0 product equal 1 3 coin add 1 second element add 1 second element subtract 1 element array 1 1 1 and 1cdot 1 cdot 1 1what minimum cost pay | 1graph
|
define beauty permutation number 1 n p_1 p_2 dot p_n number pair L R 1 le L le R le n number p_l p_L1 dot p_r consecutive RL1 number order for example beauty permutation 1 2 5 3 4 equal 9 segment correspond pair 1 2 5 4 3 1 2 3 4 5 3 4 1 2 5 3 4answer q independent query in query give integer n k Determine exist permutation number 1 n beauty equal k exist output | 1graph
|
the difference easy hard version length string you hack problem solve but hack previous problem solve problemsKirk binary string s string consist zeroes one length n ask find binary string t length satisfie follow condition for l r 1 leq l leq r leq n length long nondecrease subsequence substre s_ls_l1 ldot s_r equal length long nondecrease subsequence substre t_lt_l1 ldot t_r the number zero t maximum possibleA nondecrease subsequence stre p sequence index i_1 i_2 ldot i_k i_1 i_2 ldot i_k p_i_1 leq p_i_2 leq ldot leq p_i_k the length subsequence kIf multiple substring satisfy condition output | 1graph
|
mislove array a_1 a_2 cdot a_n n positive integer lose he remember follow fact the number different number array l great r for array element a_i a_i 1 a_i number dfraca_i2 arrayfor example n5 l2 r3 array 12244 11112 could not 12248 array contain 4 different number could not 12233 3 odd is not equal 1 could not 112216 number 16 array is not number frac162 8according fact ask count minimal maximal possible sum element array | 2string
|
the difference easy hard version complete project easy version necessary hard versionpolycarp famous freelancer his current rating r unitssome rich customer ask complete project company to complete ith project Polycarp need a_i unit rating complete project rating change b_i rating increase decrease b_i b_i positive negative Polycarps rating fall zero people will not trust low rate freelancerpolycarp choose order complete project furthermore skip project altogetherto gain experience money course Polycarp wants choose subset project have maximum possible size order complete rating start project nonnegative rating complete projectYour task calculate maximum possible size subset project | 2string
|
you give 4n stick length ith stick a_iyou create n rectangle rectangle consist exactly 4 stick give set the rectangle consist side opposite side equal length angle right note stick rectangle each stick break stick use lengthyou want rectangle equal area the area rectangle side b cdot byour task possible create exactly n rectangle equal area notyou answer q independent query | 1graph
|
you give array n integer n odd you follow operation Choose element array example a_i increase 1 replace a_i 1 you want median array large possible k operationsThe median oddsize array middle element array sort nondecrease order for example median array 1 5 2 3 5 3 | 1graph
|
Gildong buy famous painting software cfpaint the work screen cfpaint squareshape consist n row n column square cell the row number 1 n column number 1 n leave right the position cell row r column c represent r c there color cell cfpaint black whiteThere tool name eraser cfpaint the eraser integer size k 1 le k le n to use eraser Gildong need click cell j 1 le j le n k 1 when cell j clicked cell j le le k 1 j le j le j k 1 white in word square equal k cell leave corner j colored whiteA white line row column black cellsGildong work cfpaint time cell possibly zero currently black he want know maximum number white line eraser exactly help Gildong find answer question | 1graph
|
Amugae large round corridor the corridor consist area the inner area equally divided n sector outer area equally divided m sector a wall exist pair sector area inner outer wall inner area outer area a wall exist 12 oclock position the inner area sector denote 11 12 dot 1n clockwise direction the outer area sector denote 21 22 dot 2 m manner for clear understanding example image aboveAmugae want know sector sector he q questionsfor question check give sector | 1graph
|
you give sorted array a_1 a_2 dots a_n index 1 condition a_i ge a_i1 hold integer kYou ask divide array k nonempty consecutive subarray every element array include exactly subarray let maxi equal maximum ith subarray mini equal minimum ith subarray the cost division equal sumlimits_i1k maxi mini for example 2 4 5 5 8 11 19 divide 3 subarray follow way 2 4 5 5 8 11 19 cost division equal 4 2 5 5 19 8 13calculate minimum cost obtain divide array k nonempty consecutive subarray | 1graph
|
this problem differ previous absence constraint equal length number a_1 a_2 dots a_na team SIS student go trip submarine their target ancient treasure sunken ship lie Great Rybinsk sea unfortunately student do not know coordinate ship ask Meshanya hereditary mage help he agree help solve problemlets denote function alternate digits number fa_1 a_2 dot a_p 1 a_p b_1 b_2 dot b_q 1 b_q a_1 dot a_p b_1 dot b_q digit integer write decimal notation lead zerosIn word function fx y alternately shuffle digits number x y write low digit old one start number y the result function build right leave low digit old one if digit argument end remain digit argument write Familiarize example formal definition function belowfor example f1111 2222 12121212 f7777 888 7787878 f33 44444 4443434 f555 6 5556 f111 2222 2121212formally p ge q fa_1 dot a_p b_1 dot b_q a_1 a_2 dot a_p q 1 b_1 a_p q 2 b_2 dot a_p 1 b_q 1 a_p b_q p q fa_1 dot a_p b_1 dot b_q b_1 b_2 dot b_q p a_1 b_q p 1 a_2 dot a_p 1 b_q 1 a_p b_q Mishanya give array consist n integer a_i task help student calculate sum_i 1nsum_j 1n fa_i a_j modulo 998244353 | 0array
|
there n segment draw plane ith segment connect point x_i 1 y_i 1 x_i 2 y_i 2 each segment nondegenerate horizontal vertical formally 1 n x_i 1 x_i 2 y_i 1 y_i 2 condition hold only segment different type intersect pair horizontal segment share common point pair vertical segment share common pointsWe segment have index h_1 h_2 v_1 v_2 h_1 h_2 v_1 v_2 form rectangle follow condition hold segment h_1 h_2 horizontal segment v_1 v_2 vertical segment h_1 intersects segment v_1 segment h_2 intersect segment v_1 segment h_1 intersects segment v_2 segment h_2 intersect segment v_2 please calculate number way choose segment form rectangle note condition h_1 h_2 v_1 v_2 hold | 2string
|
we magic tree root tree n vertex the vertex number 1 n Vertex 1 rootThe magic tree give magic fruit the fruit grow vertex tree root each vertex contain piece fruitIt day 0 fruit ripe each fruit ripe single day for fruit give vertex v_j grow day d_j ripe w_j magic juice extract harvest ripethe fruit harvest cut branch tree on day cut branch tree like the part tree cut fall ground collect ripe fruit contain all fruit fall ground ripe discard magic juice collect themformally day erase edge tree whenever tree split multiple connect component you erase component contain root harvest ripe fruit component containedgiven description tree location ripen day juiciness m fruit calculate maximum total magic juice harvest tree | 1graph
|
you given weight undirected tree n vertex list q update each update change weight edge the task output diameter tree updateThe distance vertex sum weight unique simple path connect the diameter large distance | 1graph
|
tokitsukaze character game Kantai Collection in game character common attribute health point shorten HPIn general different value HP group 4 category Category a HP form 4 n 1 divide 4 remainder 1 Category B HP form 4 n 3 divide 4 remainder 3 category c HP form 4 n 2 divide 4 remainder 2 category D HP form 4 n divide 4 remainder 0 the abovementioned n integerThese 4 category order highest low a b c d mean category a high category d lowestwhile playing game player increase HP character now Tokitsukaze wants increase HP 2 0 1 2 how increase HP high possible category | 2string
|
tokitsukaze playing room escape game design SkywalkerT in game need find hidden clue room reveal way escapeafter realize way run away open digital door lock accidentally go secret compartment find clue interpret only enter n possible different password open door Passwords integer range 0 m 1 a password x 0 leq x m x m coprime ie x m common divisor great 1 a password x 0 leq x m exist nonnegative integer e k pe k m x p secret integer any integer do not break rule password several integer hide room p fortunately find n m record lock however make Tokitsukaze frustrated do not math now find integer suspect p want help find n possible password determine integer p | 1graph
|
tokitsukaze CSL play little game stonesin beginning n pile stone ith pile a_i stone the player turn make move Tokitsukaze move on turn player choose nonempty pile remove exactly stone pile a player lose pile turn remove stone pile possibly contain number stone Supposing player play optimally win gameconsider example n3 size pile a_12 a_23 a_30 it impossible choose pile Tokitsukaze choice second pile if choose pile state 1 3 0 good but choose second pile state 2 2 0 immediately lose so good choose pile Supposing player well move mistake win gamenote pile number stone begin Tokitsukaze able valid it necessary pile number stone move | 1graph
|
at Moscow Workshops ICPC team get balloon problem solve Team MSU Red Panda get balloon do not know spend so come problem themThere balloon 106 total colored k color we perform follow operation choose k1 balloon k1 different color recolor remain color we perform operation finite number times example perform operation k1 different color current ballshow different balloon configuration only number balloon color matter configuration differ order balloon count equal as number large output modulo 998244353 | 2string
|
let beauty array b_1 b_2 ldots b_n n 1 minlimits_1 leq j leq n b_i b_jYoure give array a_1 a_2 ldot a_n number k Calculate sum beauty subsequence array length exactly k as number large output modulo 998244353A sequence subsequence array b obtain b deletion possibly zero element | 1graph
|
the leader secretive organization decide invite member meet all member organization live town represent n crossroad connect m twodirectional street the meeting hold leader house near crossroad 1 there k member organization invite meet ith life near crossroad a_i all member organization receive message meeting moment start move location meeting hold in begin minute person locate crossroad he wait minute crossroad spend minute walk current crossroad street crossroad obviously possible start walk street begin end current crossroad in begin minute person crossroad live as soon person reach crossroad number 1 immediately come leader house attend meetingobviously leader want member organization come early possible but organization secretive leader want attract attention Lets denote discontent leader follow initially discontent 0 person reach crossroad number 1 discontent leader increase c cdot x c fix constant x number minute take person reach crossroad number 1 x member organization walk street moment direction dx2 add discontent d fix constant this cumulative example person walk street direction moment 4d add discontent 5d before send message meeting leader tell member organization path choose wait help leader establish plan member organization reach crossroad 1 discontent minimize | 2string
|
you give tree undirecte connect acyclic graph consist n vertex you play game treeinitially vertice white on turn game choose vertex paint black then turn choose white vertex adjacent connect edge black vertex paint blackeach time choose vertex turn gain number point equal size connect component consist white vertex contain choose vertex the game end vertex paint blacklet follow examplevertice 1 4 paint black if choose vertex 2 gain 4 point connect component consist vertex 2 3 5 6 if choose vertex 9 gain 3 point connect component consist vertex 7 8 9your task maximize number point gain | 1graph
|
Vasya array a_1 a_2 dot a_nyou do not know array tell m fact array the ith fact triple number t_i l_i r_i 0 le t_i le 1 1 le l_i r_i le n mean t_i1 subbarray a_l_i a_l_i 1 dot a_r_i sort nondecrease order t_i0 subbarray a_l_i a_l_i 1 dot a_r_i sort nondecrease order a subarray sort pair consecutive element subarray great for example 2 1 1 3 2 fact t_11 l_12 r_14 subarray a_2 a_3 a_4 1 1 3 sort t_20 l_24 r_25 subarray a_4 a_5 3 2 sort t_30 l_33 r_35 subarray a_3 a_5 1 3 2 sortedYou do not know array find array satisfie give fact | 1graph
|
Vus Cossack hold programming competition n people participate he decide award pen notebook it know Vus exactly m pen k notebooksDetermine Cossack reward participant give pen notebook | 1graph
|
a company n friend want order exactly pizza it know total 9 pizza ingredient nature denote integer 1 9each n friend favorite ingredient ith friend number favorite ingredient equal f_i 1 le f_i le 9 favorite ingredient form sequence b_i1 b_i2 dot b_if_i 1 le b_it le 9the website CodePizza restaurant exactly m m ge 2 pizza each pizza characterized set r_j ingredient a_j1 a_j2 dot a_jr_j 1 le r_j le 9 1 le a_jt le 9 include price c_jhelp friend choose exactly pizza way maximum number people company it know person pleased choice hisher favorite ingredient order pizza if way choose pizza maximum number friend choose minimize total price pizza | 2string
|
a sequence a_1 a_2 dot a_k call arithmetic progression 1 k element satisfy condition a_i a_1 c cdot 1 fix cFor example sequence arithmetic progression 5 7 9 11 101 101 100 99 13 97 5 5 5 5 5 and sequence are not arithmetic progression 3 1 2 1 2 4 8 1 1 1 1 1 2 3 3 3you give sequence integer b_1 b_2 dot b_n find index j 1 le j le n delete b_j sequence reorder remain n1 element arithmetic progression if index output number 1 | 2string
|
after successful field test Heidi consider deploy trap Corridor possibly she want avoid meet Daleks inside Time Vortex abundance caution consider place trap corridor go accord current Daleks plan use minimum spanning tree Corridors Heidi know energy requirement different Corridors different Daleks single unique plan intend useyour task calculate number e_maxc define way easy version ie large e le 109 change energy corridor c e dalek use corridor Heidi consider | 1graph
|
after learn polynomial hash Heidi decide learn shiftxor hash in particular come interesting problemgiven bitstring y 01n find number different k 0 leq k n exist x 01n y x oplus mboxshiftkxIn oplus xor operation mboxshiftk operation shift bitstring cyclically right k time for example 001 oplus 111 110 mboxshift300010010111000 00000010010111 | 1graph
|
the difference easy hard version constraintsA subsequence string derive string delete symbol change order remain symbol Characters delete require successively gap for example stre abaca follow string subsequence abaca aba aaa string but follow string subsequence aabaca cb bcaayou give string s consist n lowercase latin lettersin subsequence t give string add set S the set s can not contain duplicate this cost n t t length add subsequence ie price equal number delete charactersYour task find minimum possible total cost obtain set S size k report impossible | 1graph
|
this problem actually subproblem problem G contestthere n candy candy box the type ith candy a_i 1 le a_i le nYou prepare gift candy follow restriction number candy type present gift distinct ie example gift have candy type 1 candy type 2 bad it possible multiple type candy completely absent gift it possible candy type take giftYour task find maximum possible size single gift prepare candy haveyou answer q independent queriesif Python programmer consider PyPy instead Python submit code | 1graph
|
Dima work day write long paper strip favorite number n consist l digit Unfortunately strip turn long do not fit Dimas bookshelfto solve issue Dima decide split strip nonempty part contain positive integer lead zero after compute sum integer write new stripDima want result integer small possible increase chance sum fit bookshelf help Dima decide minimum sum obtain | 1graph
|