question
stringlengths
58
4.29k
label
class label
3 classes
a competitive eater Alice scheduling practice eat contest magical calendar the calendar unusual week contain necessarily 7 daysin detail choose integer k satisfie 1 leq k leq r set k day number day weekalice go paint n consecutive day calendar on calendar date write left cell right cell week if date reach day week day cell leftmost cell rowshe want paint cell connect it mean paint cell exist sequence paint cell start cell end consecutive cell sequence connect sideAlice consider shape paint cell two shape exist way exactly overlap parallel move parallel calendar sidesfor example picture week 4 day Alice paint 5 consecutive day 1 2 different shape 1 3 equal shape Alice want know possible shape exist set day week choose consecutive n day paint calendar start day week as say consider shape cell connect
1graph
Lee Master Codeforces go buy gift friend he buy n integer time distribute friend rationallyLee n integer a_1 a_2 ldot a_n backpack k friend Lee like distribute integer backpack friend ith friend exactly w_i integer integer hand exactly friendlet define happiness friend sum maximum minimum integer hell getlee like friend happy possible word he d like maximize sum friend happiness now ask calculate maximum sum friend happiness
0array
Arthur own ski resort mountain there n land spot mountain number 1 n foot mountain the spot connect onedirectional ski track all track foot mountain direct cycle form track there track leave spot track enter spota skier start ski spot stop spot sequence track lead start spot end end spot unfortunately recently accident structure resort allow skier dangerous path reach high speed endanger customer here path call dangerous consist tracksarthur want secure customer closing spot way dangerous path resort when spot close track enter leave spot unusable Formally closing spot path consist tracksArthur do not want close spot he happy find way close frac47n spot remain safe help find suitable way
2string
this easy version problem in version number give array distinct constraint n hard version problemyou give array n integer equal element array you perform follow operation array element choose index 1 le le n element ai begin array choose index 1 le le n element ai end array for example n 5 4 7 2 3 9 follow sequence operation perform perform operation type second element array 7 4 2 3 9 perform operation second type second element array 7 2 3 9 4 you perform operation type number time orderfind minimum total number operation second type array sort nondecrease order in word minimum number operation perform array satisfie inequalitie a1 le a2 le ldots le
1graph
polycarp friend want visit new restaurant the restaurant n table arrange straight line People sit table the table number 1 n order leave right the state restaurant describe string length n contain character 1 table occupy 0 table emptyrestaurant rule prohibit people sit distance k that person sit table number table number ik ik ith free in word absolute difference number occupy table strictly great kFor example n8 k2 string 10010001 10000010 00000000 00100000 satisfy rule restaurant string 10100100 10011001 11111111 satisfy rule restaurant pair 1 distance equal k2 in particular state restaurant describe stre 1 string 1 requirement restaurant satisfiedyou give binary string s describe current state restaurant it guarantee rule restaurant satisfied string sFind maximum number free table occupy violate rule restaurant formally maximum number 0 replace 1 requirement satisfiedfor example n6 k1 s100010 answer problem 1 table position 3 occupy rule satisfy
1graph
let denote function fs take string s consist lowercase latin letter dot return string consist lowercase Latin letter follow let r string process character s leave right for character c follow c lowercase latin letter append c end stre r delete character r r delete character function crash return r result function you give string s t you delete minimum possible number character s fs t function crash Note are not allow insert new character s reorder exist one
2string
you give simple weight connect undirected graph consist n vertex m edgesA path graph length k sequence k1 vertice v_1 v_2 dot v_k1 1 le le k edge v_i v_i1 present graph a path vertex v vertex v_1v Note edge vertex allow include path multiple timesthe weight path total weight edge itfor 1 q consider path vertex 1 length maximum weight what sum weight q pathsansw large print modulo 1097
1graph
you give array consist n integer a_1 a_2 a_n initially a_x 1 element equal 0you perform m operation during ith operation choose index c d l_i le c d le r_i swap a_c a_dcalculate number indice k possible choose operation a_k 1 end
1graph
Vivek encounter problem he maze represent n time m grid each grid cell represent follow Empty Wall good person g bad person b the escape maze cell n mA person cell share current cell contain wall Vivek want block cell replace wall way good people able escape bad people able a cell initially contain G B block travel throughhelp determine exist way replace zero cell wall satisfy conditionsIt guarantee cell nm Vivek block cell
2string
ashish n element arrange line these element represent integer a_i value element b_i type element possible type 0 1 he want sort element nondecrease value a_ihe perform follow operation number time Select element j b_i ne b_j swap that swap element different type tell sort element nondecrease value a_i perform number operation
1graph
give array length n find array b length n 1 le le n MEXb_1 b_2 ldot b_ia_i the MEX set integer smallest nonnegative integer do not belong setIf array do not exist determine
2string
Ehab love number theory reason hate number x give array find length long subarray sum element is not divisible x determine subarray do not existan array subarray array b obtain b deletion possibly zero element begin possibly zero element end
1graph
ashish tree consist n node number 1 n root node 1 the ith node tree cost a_i binary digit b_i write he want binary digit c_i write ith node endTo achieve perform follow operation number time Select k node subtree node u shuffle digits nod wish incur cost k cdot a_u here choose k range 1 size subtree u he want perform operation way node finally digit correspond targethelp find minimum total cost need spend operation node u digit c_u write determine impossible
1graph
Johnny recently find ancient broken computer the machine register allow variable then operation shift bit leave right position the right shift forbid cut one so fact operation multiply divide number 2 4 8 division allow number divisible choose divisor Formally register contain positive integer x operation replace follow x cdot 2 x cdot 4 x cdot 8 x 2 x divisible 2 x 4 x divisible 4 x 8 x divisible 8 for example x 6 operation replace 12 24 48 3 value 6 is not divisible 4 8 there re variant replacementnow Johnny wonder operation need perform put register want b end
1graph
James Bond Johnnys favorite secret agent new mission there n enemy basis describe coordinate think point cartesian plane the basis communicate send signal ray direct choose point origin opposite direction the exception central base lie origin send signal direction when basis want communicate possible scenario if lie line origin send signal directly Otherwise signal send base central central send second base we denote distance basis total euclidean distance signal send travelbond damage k basis choose arbitrarily a damage base can not send receive direct signal pass work basis in particular James damage central base signal send undamaged basis distance remain what maximal sum distance pair remain basis 007 achieve damaging exactly n k
2string
Johnny find new great tutorial how grandmaster the tutorial tell strange unexpected Johnny thing patient important solve hard hard problem the boy find online judge task divide topic cover he pick pk_i problem ith category p favorite number he want solve week patience condition hard Johnny simplicity look easy task solve period now future grandmaster decide topic cover second week help assign topic way workload balancedformally give n number pk_i boy want divide disjoint set minimize absolute difference sum number set find minimal absolute difference output result modulo 1097
2string
polycarp wants buy exactly n shovel the shop sell package shovel the store k type package package ith type consist exactly shovel 1 le le k the store infinite number package typepolycarp want choose type package buy package type what small number package Polycarp buy exactly n shovelsfor example n8 k7 Polycarp buy 2 package 4 shovelshelp Polycarp find minimum number package need buy give buy exactly n shovel total size package buy number shovel package integer 1 k inclusive
1graph
levian work accountant large company Levian know company earn n consecutive month ith month company income equal a_i positive income mean profit negative income mean loss zero income mean change because general selfisolation lceil tfracn2 rceil month income completely unstable stabilize lfloor tfracn2 rfloor month income sameLevian decide tell director nk1 number total income company k consecutive month in word 1 nk1 value a_i a_i1 ldot a_i k 1 for example a1 0 1 2 2 k3 number 0 3 5unfortunately total income report levian profit income le 0 director angry fire fail accountantsave Levians career find k k month row company profit report impossible
1graph
implement operation equivalent operation qft1p QFT quantum fourier transform in word operation apply P time effect apply QFT you implement require transformation global phaseyour operation follow inputs integer P 2 le P le 8 register type LittleEndian wrapper type array qubit encode unsigned integer littleendian format significant bit write corresponding array element index 0 if need convert array type unwrap operator let qubitarray inputregister the register contain 7 qubit the output solution state leave input qubitsYour code follow signature note operation Adjoint control variant define adjctl operation signature generate automatically base codenamespace solution open microsoftquantumarithmetic open microsoftquantumintrinsic operation Solve p Int inputregister LittleEndian Unit adjctl code you learn QFT kata you allow advantage library operation include QFTLE
1graph
implement operation equivalent operation QFTP QFT quantum Fourier transformyour operation follow inputs integer P 2 le P le 21cdot 106 register type LittleEndian wrapper type array qubit encode unsigned integer littleendian format significant bit write corresponding array element index 0 if need convert array type unwrap operator let qubitarray inputregister the output solution state leave input qubitsYour code follow signature note operation Adjoint control variant define adjctl operation signature generate automatically base codenamespace solution open microsoftquantumarithmetic open microsoftquantumintrinsic operation Solve p Int inputregister LittleEndian Unit adjctl code you learn QFT kata you allow advantage library operation include QFTLE implement necessary transform power
1graph
you give operation implement singlequbit unitary transformation H gate X gate the operation Adjoint Controlled variant definedYour task perform necessary operation measurement figure unitary return 0 h gate 1 x gate you allow apply give operation adjointcontrolle variant twiceyou implement operation take singlequbit operation input return integer your code follow signaturenamespace solution open microsoftquantumintrinsic operation Solve unitary Qubit Unit AdjCtl Int code
1graph
you give operation implement singlequbit unitary transformation identity I gate X gate the operation Adjoint Controlled variant definedYour task perform necessary operation measurement figure unitary return 0 I gate 1 x gate you allow apply give operation adjointcontrolle variant exactly onceyou implement operation take singlequbit operation input return integer your code follow signaturenamespace solution open microsoftquantumintrinsic operation Solve unitary Qubit Unit AdjCtl Int code
0array
this interactive problem do not forget flush output print query coutflush fflushstdout C similar function programming languagesthere n gift box row number 1 n leave right its know exactly k contain valuable gift box contain lucky stone all box look differ weight all box stone weight strictly heavy box valuable item but valuable gift different box valuable item different weightsyou ask 50 query print answer do not count by query compare total weight nonintersecte subset box a_1 a_2 dots a_k_a b_1 b_2 dot b_k_b in return you ll result FIRST subset a_1 a_2 dots a_k_a strictly heavy SECOND subset b_1 b_2 dot b_k_b strictly heavy equal subset equal total weight waste query incorrect limit query exceed use query maybe intuition find box valuable gift minimum index
2string
you give stre s character 1 2 3 you choose short contiguous substring s contain character oncea contiguous substre string s string obtain s remove possibly zero character begin s possibly zero character end s
1graph
you give garland consist n lamp States lamp represent string s length n the ith character string s_i equal 0 ith lamp turn 1 ith lamp turn you give positive integer kIn choose lamp change state ie turn turn vice versaThe garland call kperiodic distance pair adjacent turn lamp exactly k consider case k3 then garland 00010010 1001001 00010 0 good garland 00101001 1000001 01001100 note garland cyclic ie turn lamp going turn lamp vice versaYour task find minimum number move need obtain kperiodic garland give oneYou answer t independent test case
1graph
you give array b consist n positive great zero integer you give integer kIn choose index j 1 le j le n swap a_i b_j ie a_i b_j vice versa Note j equal different particular swap a_2 b_2 swap a_3 b_9 acceptable movesYour task find maximum possible sum obtain array ie k move swapsyou answer t independent test case
2string
you give integer n m you construct array length n consist nonnegative integer ie integer greater equal zero sum element array exactly m value sumlimits_i1n1 a_i a_i1 maximum possible Recall x absolute value xIn word maximize sum absolute difference adjacent consecutive element for example array a1 3 2 5 5 0 value array 13 32 25 55 50 2 1 3 0 5 11 note example do not optimal answer show require value array calculatedYou answer t independent test case
1graph
there n candy row number leave right 1 n the size ith candy a_ialice Bob play interesting tasty game eat candy Alice eat candy leave right Bob right leave the game end candy eatenthe process consist move during player eat sweet herhis Alice eat leave Bob rightalice make during eat 1 candy size a_1 then successive player alternate Bob make second Alice Bob onon player count total size candy eat current once number strictly great total size candy eat player previous current player stop eat end in word player eat small possible number candy sum size candy eat strictly great sum size candy player eat previous if candy way player eat remain candy game endsFor example n11 a31415926535 1 Alice eat candy size 3 sequence candy 1415926535 2 Alice eat 3 previous mean Bob eat 4 Bob eat candy size 5 sequence candy 141592653 3 Bob eat 5 previous mean Alice eat 6 Alice eat candy total size 1416 sequence candy 592653 4 Alice eat 6 previous mean Bob eat 7 Bob eat candy total size 358 sequence candy 5926 5 Bob eat 8 previous mean Alice eat 9 Alice eat candy total size 5914 sequence candy 26 6 Alice eat 14 previous mean Bob eat 15 it impossible Bob eat remain candy game end print number move game number total size sweet eat Alice game b total size sweet eat Bob game
1graph
Vasya claim paper square he cut rectangular part vertical horizontal cut then Vasya inform dimension rectangular part you need check Vasya originally square in word check possible square give rectangle
2string
there n model shop number 1 n size s_1 s_2 ldot s_norac buy model arrange order increase number ie index sizesOrac think obtain arrangement beatiful adjacent model indice i_j i_j1 note i_j i_j1 Orac arrange properly i_j1 divisible i_j s_i_j s_i_j1For example 6 model size 3 6 7 7 7 7 buy model indice 1 2 6 obtain arrangement beautiful also note arrangement exactly model consider beautifulorac wants know maximum number model buy ask query time
1graph
slime Orac hold turnbase game in big room n player sit chair look forward column give number player 1 sit column player 2 sit directly player 3 sit directly player 2 player n sit directly player n1 each player wear hat black white as player face forward player know color player js hat large jAt start turn Orac tell exist player wear black hat roomafter Orac speak player uniquely identify color hat hat chair stand leave room all player smart possible understand color hat obtain information previous round understand in turn player know color hat leave time turn mean player leave turn get know color hat leave room turnNote player need leave hat chair leave player ahead hat the ith player know exactly leave room player 12ldotsi1 player i1i2ldotsn leave roomslime stand outdoor he watch player walk record number player time unfortunately Slime careless record datum give data format player x leave yth roundslime ask tell color player hat if multiple solution find
2string
please notice unusual memory limit problemorac like game recently come new game Game LifeYou play game black white grid n row m column each cell black whiteFor iteration game initial iteration 0 color cell change follow rule if adjacent cell color cell current iteration color iteration otherwise color cell iteration differentTwo cell adjacent mutual edgenow Orac set initial situation wants know cell ij ith row jth column color iteration p he ask question time
1graph
for multiset positive integer ss_1s_2dotss_k define Greatest Common Divisor GCD Least Common Multiple LCM s follow gcd maximum positive integer x integer s divisible x textrmlcms minimum positive integer x divisible integer sFor example gcd8124gcd121866 textrmlcm4612 Note positive integer x gcdxtextrmlcmxxorac sequence length n he come multiset ttextrmlcma_ia_j ij ask find value gcdt in word need calculate GCD LCMs pair element give sequence
1graph
polycarp develop new version old video game PacMan though enjoy play original game do not like aspect decide alter rule bitin Polycarps version play PacMan collect pellet scatter game world avoid dangerous ghost difference original Polycarp do not like fact escape ghost original version game world divide n safe zone m onedirectional pathway guarantee PacMan reach safe zone since safe zone safe ghost attack PacMan danger traverse pathway PacMan start game safe zone sAll pellet scatter safe zone initially ith safe zone contain a_i pellet PacMan safe zone freely collect pellet the pellet disappear collect pellet game world collect new pellet spawn safe zone quantity a_i new pellet spawn ith zone the pellet respawne number time game essentially infinitepolycarp determined structure game world number pellet safe zone now try find game difficult there q goal game ith goal collect c_i pellet begin game Polycarp denote difficulty ith goal minimum number time player traverse onedirectional pathway order collect c_i pellet traverse pathway put PacMan danger if pathway traverse multiple time PacMan collect pellet include answer number timeshelp polycarp calculate difficulty goal
1graph
you re mission old popular strategy game Dune II Battle for Arrakis the map mission represent rectangular matrix size n time m initially a_i j unit army cell jYou want prepare final battle want army exactly cell map ie nm1 cell contain 0 unit army remain cell contain entire armyto possibly zero number move during select exactly unit cell adjacent cell Ie cell j unit cell 1 j j 1 1 j j 1 of course want army exactly cell fast possible so want know minimum number move need thatand course life go situation map change there q update ith update denote integer x y z this update affect army cell x y update number unit cell x y z ie replace a_x y zAlso want determine minimum number move need entire army exactly cell update apply initial map in word map ith update equal initial map update apply
2string
polycarp develop RPG game main character fight monster search treasure dungeon now Polycarp make dungeon character explorethe dungeon consist n room connect m twoway tunnel possible reach room room tunnel the room guard monster number monster ith room a_i tunnel contain gold coin number coin ith tunnel w_i the ith twoway tunnel connect room v_i u_ipolycarp fix number coin tunnel value w_i know try place monster room value a_i know Polycarp wants choose number monster room way follow condition meet number coin tunnel connect room x y equal minimum a_x a_y that tunnel w_i min a_v_i a_u_i number monster dungeon small possible that value a_1 a_2 dot a_n minimum possible help Polycarp choose value a_1 a_2 a_n tell impossible change dungeon plan
2string
Piet Mondrian artist famous minimalist work consist color red yellow blue white Most people attribute style truth paint behave strange way mix primary color produce primary color a lesser know piece entitle pretentious rectangle a sequence primary color red yellow blue mixed follow while color look if distinct replace miss color if remove sequence in end color result color otherwise sequence result color white here example mixing piet color palette cell number 1 n each cell contain primary color Piet secretive share palette know color belong cellhowever perform k operation there kind operation in mix operation Piet choose subset cell mix color order the order necessarily increase index he record result color empty cell skip have effect mix process the mix change color value store cell in ry operation Piet choose subset cell any red cell subset yellow yellow cell subset red Blue cell remain unchanged in RB operation Piet choose subset cell any red cell subset blue blue cell subset red Yellow cell remain unchanged in yb operation Piet choose subset cell any yellow cell subset blue blue cell subset yellow Red cell remain unchanged Piet tell list operation perform chronological order index involve result color mix operation for mix operation know order cell mix give information determine color cell initial palette that find possible state palette operation perform describe situation impossible
1graph
recently Vova find n candy wrapper he remember buy x candy day 2x candy second day 4x candy day dot 2k1 x candy kth day but issue Vova remember x k sure x k positive integer k 1Vova satisfied tell positive integer x integer k1 x 2x 4x dot 2k1 x n it guarantee solution exist note k 1you answer t independent test case
1graph
let string s period k s_i s_i k 1 s k s mean length string s k minimum positive integer propertySome example period s0101 period k2 s0000 period k1 s010 period k2 s0011 period k4you give string t consist 0s 1s need find string s String s consist 0s 1s the length s do not exceed 2 cdot t string t subsequence stre s String s small possible period string meet condition 13 let recall t subsequence s t derive s delete zero element change order remain element for example t011 subsequence s10101
1graph
you give integer x y you perform type operation pay dollar increase decrease integer 1 for example x 0 y 7 possible outcomes operation x 0 y 6 x 0 y 8 x 1 y 7 x 1 y 7 pay b dollar increase decrease integer 1 for example x 0 y 7 possible outcomes operation x 1 y 6 x 1 y 8 your goal give integer equal zero simultaneously ie x y 0 there requirement in particular possible x1 y0 xy0calculate minimum dollar spend
1graph
you unweighte tree n vertex you assign positive weight edge follow condition hold for different leave v_1 v_2 tree bitwise XOR weight edge simple path v_1 v_2 equal 0 note large positive integer like 101010its guarantee assignment exist give constraint now let define f number distinct weight assignment in example assignment valid bitwise XOR edge weight pair leave 0 f value 2 2 distinct edge weights4 5 in example assignment invalid bitwise XOR edge weight vertex 1 vertex 6 3 4 5 4 0 what minimum maximum possible value f give tree find print
1graph
the difference easy hard version constraintsyou give sequence consist n positive integerslet define block palindrome sequence consist distinct element let element b equal b follow underbracea dot a_x underbraceb b dot b_y underbracea dot a_x there x y integer greater equal 0 for example sequence 2 1 1 1 2 1 1 2 2 1 1 1 2 1 1 block palindrome 1 2 3 2 1 1 2 1 2 1 1 2 notyour task choose maximum length subsequence block palindromeyou answer t independent test casesrecall sequence t subsequence sequence s t derive s remove zero element change order remain element for example s1 2 1 3 1 2 1 possible subsequence 1 1 1 1 3 1 2 1 3 1 2 1 3 2 3 1 1 1 1 2
0array
let denote follow function f this function take array length n return array initially result array for integer 1 n add element a_i end result array great previous element formally a_i maxlimits_1 le j ia_j some example function f 3 1 2 7 7 3 6 7 8 fa 3 7 8 1 fa 1 4 1 1 2 3 fa 4 1 3 1 2 6 8 7 7 4 11 10 fa 1 3 6 8 11 you give array array a_1 a_2 dots a_n array b_1 b_2 dot b_m you delete element array possibly zero to delete element a_i pay p_i coin value p_i negative p_i coin delete element Calculate minimum number coin possibly negative spend fulfil equality fa b
2string
Kate set S n integer 1 dot n she think imperfection subset M subseteq S equal maximum gcda b pairs b b M neq b Kate neat girl k 2 dot n wants find subset small imperfection subset S size k there subset small imperfection size do not need worry Kate wants find subset need help find small possible imperfection size k i_k please help Kate find I_2 I_3 i_n
1graph
eugene like work array and today need help solve challenge taskan array c subarray array b c obtain b deletion possibly zero element begin possibly zero element endlet nonempty array good nonempty subarray array sum element subarray nonzero for example array 1 2 3 good array 1 1 2 1 2 3 2 2 3 3 nonzero sum element however array 1 2 1 3 is not good subarray 1 2 1 sum element equal 0help eugene calculate number nonempty good subarray give array
1graph
give sequence integer length n tuple ijk call monotone triple 1 le ijkle n a_i le a_j le a_k a_i ge a_j ge a_k satisfy for example a5345 234 monotone triple sequence 134 notBob give sequence integer length n math exam the exam contain question form L R ask find subsequence b size great 2 ie b ge 3 sequence a_L a_l1ldots a_rrecall sequence b subsequence sequence b obtain deletion possibly zero elementshowever hate monotone stuff wants find subsequence free monotone triple besides want find subsequence large length subsequence free monotone triple queryplease help Bob find subsequence meeting constraint
2string
Eric teacher graph theory class Today Eric teach independent set edgeinduce subgraphgiven graph GVE independent set subset vertex V subset V pair uv v uv e ie edge e connect vertex VAn edgeinduce subgraph consist subset edge E subset E vertex original graph incident edge subgraphGiven e subset E denote GE edgeinduce subgraph E edge set subgraph here illustration definition in order help student familiar definition leave follow problem exercisegiven tree GVE calculate sum wH null edgeinduce subgraph h g wH number independent set H formally calculate sum limits_emptyset e subset E wgeshow Eric smart student provide correct answer quickly possible note answer large output answer modulo 998244353
1graph
a positive integer call composite represent product positive integer great 1 for example follow number composite 6 4 120 27 the follow number are not 1 2 3 17 97alice give sequence n composite number a_1a_2ldotsa_nshe wants choose integer m le 11 color element m color 1 m color 1 m element color element colored color exactly color great common divisor element color color great 1 ie gcda_i a_j1 pair j element color color note equal element color different color choose m color index 1 nAlice show a_i le 1000 solve task choose m le 11help Alice find require color note do not minimize maximize number color find solution m 1 11
1graph
InputThe input contain single integer 0 le le 63outputoutput single numberexamplesinput2output2input5output24input35output50
1graph
Dreamoon big fan Codeforces contestsOne day claim collect place 1 54 rate contest its amazingbase come follow problemThere person participate n Codeforces round his place round a_1 place second round a_2 place nth round a_nyou give positive nonzero integer xPlease find large v person collect place 1 v x rate contestsin word need find large v possible x rate contest 1 leq leq v exist contest person take ith placeFor example n6 x2 a3115710 answer v5 contest place 2 4 collect place 1 5 possible v5
2string
Dreamoon like string today create game stringsstre s_1 s_2 ldot s_n beautiful 1 le n s_i ne s_i1initially Dreamoon string in step Dreamoon choose beautiful substre remove then concatenate remain character orderdreamoon want use small number step please help Dreamoon print sequence small number step
1graph
Dreamoon like sequence so create problem sequence can not find OEIS you give integer d m find number array satisfy follow constraint the length n n ge 1 1 le a_1 a_2 dots a_n le d Define array b length n follow b_1 a_1 forall 1 b_i b_i 1 oplus a_i oplus bitwise exclusiveor xor after construct array b constraint b_1 b_2 dots b_n 1 b_n hold since number possible array large need find answer modulo m
1graph
you give positive integer b in increase 1 replace a1 your task find minimum number move need order divisible b it possible 0 move divisible b you answer t independent test case
1graph
you write integer 0 10n 1 padding lead zeroes length exactly n for example n 3 write 000 001 998 999a block integer x consecutive segment equal digit extend left rightfor example integer 00027734000 block length 1 block length 2 block length 3for integer 1 n count number block length write integerssince integer large print modulo 998244353
2string
Petya rectangular Board size n time m initially k chip place board ith chip locate cell intersection sx_ith row sy_ith columnin action Petya chip leave right 1 cellIf chip x y cell operation leave coordinate x y 1 right coordinate x y 1 coordinate x 1 y coordinate x 1 y if chip locate wall board action choose Petya move wall chip remain current positionnote chip locate cellFor chip Petya choose position visit note necessary chip end positionsince Petya lot free time ready 2 nm actionsYou find action Petya chip visit position Petya select or determine possible 2 nm action
2string
you give permutation p_1 p_2 ldot p_nimagine position permutation contain bomb exist position bombfor fix configuration bomb consider follow process initially set AFor 1 n add p_i a if ith position contain bomb remove large element aafter process complete a nonempty the cost configuration bomb equal large element AYou give permutation q_1 q_2 ldot q_nFor 1 leq leq n find cost configuration bomb exist bomb position q_1 q_2 ldot q_i1 for example i1 need find cost configuration bomb need find cost configuration bomb position q_1 q_2 ldot q_n1
1graph
you give positive integer x find 2 positive integer b gcdablcmabxas reminder GCDab great integer divide b similarly lcmab small integer b divide itits guarantee solution exist if pair b output
1graph
you give array consist n integersYour task determine subsequence length 3 palindromerecall array b call subsequence array b obtain remove possibly zero element necessarily consecutive change order remain element for example 2 1 2 1 3 2 3 subsequence 1 2 1 3 1 1 2 4 notalso recall palindrome array read backward forward in word array length n palindrome a_i a_n 1 1 n for example array 1234 1 2 1 1 3 2 2 3 1 10 100 10 palindrome array 1 2 1 2 3 1 notyou answer t independent test case
1graph
you give Tetris field consist n column the initial height ith column field a_i block on column place figure size 2 time 1 ie height figure 2 block width figure 1 block Note rotate figuresyour task clear field place figuresmore formally problem describe like thisthe following process occur a_i great 0 you place figure 2 time 1 choose 1 n replace a_i a_i 2 a_i great zero replace a_i a_i 1 and task determine possible clear field ie finish describe process choose place new figure properlyyou answer t independent test case
1graph
roma play new expansion favorite game World Darkraft he new character go grindroma choice buy exactly n different weapon exactly m different armor set Weapon attack modifier a_i worth ca_i coin armor set j defense modifier b_j worth cb_j coinsafter choosing equipment Roma proceed defeat monster there p monster try defeat Monster k defense x_k attack y_k possess z_k coin Roma defeat monster weapon attack modifier large monster defense armor set defense modifier large monster attack that monster k defeat weapon armor set j a_i x_k b_j y_k after defeat monster Roma take coin during grind Roma defeat monster like Monsters respawn monster defeat onethanks Romas excessive donation assume infinite ingame currency afford weapon armor set still want maximize profit grind the profit define total coin obtain defeat monster minus cost equipment Note Roma purchase weapon armor set cover cost obtain coinshelp Roma find maximum profit grind
1graph
Vasya string b s consist lowercase english letter the length string b equal n length string s equal m Vasya decide choose substre string choose substre string b concatenate Formally choose segment l_1 r_1 1 leq l_1 leq r_1 leq n segment l_2 r_2 1 leq l_2 leq r_2 leq n concatenation obtain stre al_1 r_1 bl_2 r_2 a_l_1 a_l_1 1 ldot a_r_1 b_l_2 b_l_2 1 ldot b_r_2Now Vasya interested counting number way choose segment adhere follow condition segment l_1 r_1 l_2 r_2 nonempty intersection ie exist integer x l_1 leq x leq r_1 l_2 leq x leq r_2 string al_1 r_1 bl_2 r_2 equal string s
0array
the Red Kingdom attack White King Black KingThe Kingdom guard n castle ith castle defend a_i soldier to conquer Red Kingdom king eliminate defender each day White King launch attack castle then night force Black King attack castle possibly then White King attack castle Black King the attack perform White KingEach attack target castle alive defender there type attack mixed attack decrease number defender target castle x set 0 x defender infantry attack decrease number defender target castle y set 0 y defender cavalry attack decrease number defender target castle z set 0 z defender the mixed attack launch valid target castle soldier however infantry attack launch previous attack target castle type matter launch the applie cavalry attack a castle attack targeted type attackthe King launch attack glorify conqueror Red Kingdom king want launch attack wise find strategy allow matter action opponent strategy exist the White King lead attack responsible planning can calculate number possible option attack allow White King launch attack each option attack represent target castle type attack option different target castle type attack different
2string
there n point coordinate axis OX the ith point locate integer point x_i speed v_i it guarantee point occupy coordinate all n point constant speed coordinate ith point moment t t noninteger calculate x_i t cdot v_iconsider point j Let di j minimum possible distance point possible moment time noninteger it mean point j coincide moment value di j 0your task calculate value sumlimits_1 le j le n di j sum minimum distance pair point
1graph
you want perform combo opponent popular fighting game the combo string s consist n lowercase latin letter to perform combo press button order appear s ie sabca press b c againyou know spend m wrong try perform combo ith try mistake right p_ith button 1 le p_i n ie press p_i button right start perform combo beginning it guarantee m1th try press button right finally perform comboie sabca m2 p 1 3 sequence press button you re make mistake start perform combo begin b c you re make mistake start perform combo beginning note point perform combo mistake b c aYour task calculate button letter number time you ll press itYou answer t independent test case
1graph
in modern cryptography tie algorithmic complexity solve problem one problem discrete logarithm problem it formulate follow Lets fix finite field element b one need fun x ax b detect x it likely modern mankind solve problem discrete logarithm sufficiently large field size for example field residue modulo prime number prime 1024 2048 bit consider safe however calculation large number place significant load server perform cryptographic operation for reason instead simple module residue field complex field for field fast algorithm use field structure know small field operation properly optimize Developer Nikolai trust generally accept method want invent recently read strange field nimber think great fit purpose the field nimber define set integer 0 22k 1 positive integer k Bitwise exclusive oplus operation addition one way define multiplication operation odot follow property 0 odot odot 0 0 1 odot odot 1 odot b b odot odot b odot c odot b odot c odot b oplus c odot b oplus odot c if 22n integer n 0 b odot b cdot b if 22n integer n 0 odot frac32cdot for example 4 odot 4 6 8 odot 8 4 odot 2 odot 4 odot 2 4 odot 4 odot 2 odot 2 6 odot 3 4 oplus 2 odot 3 4 odot 3 oplus 2 odot 2 oplus 1 4 odot 3 oplus 2 odot 2 oplus 2 odot 1 12 oplus 3 oplus 2 13 32 odot 64 16 odot 2 odot 16 odot 4 16 odot 16 odot 2 odot 4 24 odot 8 16 oplus 8 odot 8 16 odot 8 oplus 8 odot 8 128 oplus 13 141 5 odot 6 4 oplus 1 odot 4 oplus 2 4odot 4 oplus 4 odot 2 oplus 4 odot 1 oplus 1 odot 2 6 oplus 8 oplus 4 oplus 2 8 Formally algorithm describe follow pseudocode multiplya b an 0 p1 bitsa number bit equal p2 bitsb number bit b equal ans an xor multiply_powers_of_21 p1 1 p2 return ansmultiply_powers_of_2a b 1 b 1 return b n maximal value 22n maxa b power 22n power b power return multiplypower 3 2 multiply_powers_of_2a power b power power return multiply_powers_of_2a power b power return multiply_powers_of_2a b power power it show operation form field moreover sense game theory operation that s related problem with help appropriate cache group operation possible calculate product quickly important improve speed cryptoalgorithm more formal definition additional property clarify wikipedia article link the author task hope property list statement solution powering muliplication define way formally aodot k underbracea odot odot cdot odot a_ktexttttimesyou need analyze propose scheme strength for pair number b need find x aodot x b determine do not exist
2string
let define function f multiset multiset number occurence number present aeg f5 5 1 2 5 2 3 3 9 5 1 1 2 2 4let define fka apply f array k times fka ffk1a f0a Eg f25 5 1 2 5 2 3 3 9 5 1 2 2you give integer n k ask different value function fka arbitrary nonempty array number size n Print answer modulo 998244353
1graph
VK news recommendation system daily select interesting publication n disjoint category user each publication belong exactly category for category batch algorithm select a_i publicationsthe late AB test suggest user read recommend publication actively category different number publication daily recommendation the target algorithm find single interesting publication ith category t_i second what minimum total time necessary add publication result batch algorithm execution category different number publication you can not remove publication recommend batch algorithm
1graph
bessie cow intercept text Farmer John send Burger Queen however Bessie sure secret message hide insidethe text string s lowercase latin letter she consider string t hide string s t exist subsequence s index form arithmetic progression for example stre aab hidden string aaabb occur index 1 3 5 form arithmetic progression common difference 2 Bessie think hidden string occur time secret message two occurrence subsequence s distinct set index different help find number occurrence secret messagefor example string aaabb hide 3 time b hide 2 time ab hide 6 time aa hide 3 time bb hide 1 time aab hide 2 time aaa hide 1 time abb hide 1 time aaab hide 1 time aabb hide 1 time aaabb hide 1 time the number occurrence secret message 6
2string
the USA Construction Operation USACO recently order Farmer John arrange row n haybale pile farm the ith pile contain a_i haybale however Farmer John leave vacation leave Bessie every day Bessie naughty cow choose haybale pile adjacent pile Formally day choose index j 1 le j le n ij1 a_i0 apply a_i a_i 1 a_j a_j 1 she decide day lazyBessie want maximize number haybale pile 1 ie maximize a_1 d day Farmer John return help find maximum number haybale pile 1 act optimally
1graph
Kuroni coordinator Mathforces round write Proof AC team all preparation discuss team score distribution roundthe round consist n problem number 1 n the problem order increase order difficulty problem difficulty a score distribution round denote array a_1 a_2 dot a_n a_i score ith problem Kuroni think score distribution satisfy follow requirement the score problem positive integer exceed 109 a hard problem grant strictly high score easy problem in word 1 leq a_1 a_2 dot a_n leq 109 the balance score distribution define number triple j k 1 leq j k leq n a_i a_j a_k exactly m help team find score distribution satisfie Kuronis requirement in case score distribution exist output 1
2string
to king Codeforces Kuroni solve follow problemhe give n number a_1 a_2 dot a_n help Kuroni calculate prod_1le ijle n a_i a_j as result big output modulo mif familiar short notation prod_1le ijle n a_i a_j equal a_1 a_2cdota_1 a_3cdot dot cdota_1 a_ncdota_2 a_3cdota_2 a_4cdot dot cdota_2 a_n cdot dot cdot a_n1 a_n in word product a_i a_j 1le j le n
1graph
Kuroni n daughter as gift buy n necklace n bracelet ith necklace brightness a_i a_i pairwise distinct ie a_i different ith bracelet brightness b_i b_i pairwise distinct ie b_i different Kuroni want exactly necklace exactly bracelet daughter to sure look unique total brightness gift give daughter pairwise distinct Formally ith daughter receive necklace brightness x_i bracelet brightness y_i sum x_i y_i pairwise distinct Help Kuroni distribute giftsfor example brightnesse 1 7 5 b 6 1 2 distribute gift follow Give necklace bracelet daughter total brightness a_3 b_1 11 Give necklace bracelet second daughter total brightness a_1 b_3 3 give second necklace second bracelet daughter total brightness a_2 b_2 8 here example invalid distribution Give necklace bracelet daughter total brightness a_1 b_1 7 give second necklace second bracelet second daughter total brightness a_2 b_2 8 Give necklace bracelet daughter total brightness a_3 b_3 7 this distribution invalid total brightness gift receive daughter do not upset
1graph
Being tired participate Codeforces round Gildong decide rest park he sit bench soon find rabbit hop one rabbit tall otherHe notice rabbit hop the position rabbit represent integer coordinate horizontal line the tall rabbit currently position x short rabbit currently position y x lt y every second rabbit hop position the tall rabbit hop positive direction short rabbit hop negative direction b for example let x0 y10 a2 b3 at 1st second rabbit position 2 7 at 2nd second rabbit position 4Gildong wonder will rabbits position moment if long Lets find moment time second rabbit point
1graph
you give stre s you build new string p s follow operation time choose subsequence s_i_1 s_i_2 dot s_i_k 1 le i_1 i_2 dot i_k le s erase choose subsequence s s concatenate choose subsequence right string p word p p s_i_1s_i_2dot s_i_k of course initially stre p for example let s textababcd at let choose subsequence s_1 s_4 s_5 textabc s textbad p textabc at second let choose s_1 s_2 textba s textd p textabcba so build textabcba textababcdCan build give string t algorithm
2string
polycarp wants assemble keyboard layout multiple row complicate keyboard consist row 26 lowercase Latin letter arrange orderpolycarp use password s website register bad do not care he want assemble keyboard allow type password easily he do not like finger type password pair adjacent character s adjacent keyboard for example password abacaba layout cabdefghi perfect character c adjacent keyboard b adjacent keyboard it guarantee adjacent equal character s example password password character s adjacentcan help polycarp choose perfect layout keyboard possible
2string
this unusual problem unusual contest announcement httpcodeforcescomblogentry73543you safe lock consist 5 decimal digit if rotate digit increase 9 0initially lock contain number x to unlock safe follow operation order careful do not mix statementsif sum digit position 3 4 great 10 rotate digit position 2 9 time rotate digit position 5 4 timesif digit position 3 great digit position 5 rotate digit position 2 4 time rotate digit position 4 6 timesif digit position 5 great digit position 3 rotate digit position 2 1 time rotate digit position 1 7 timesif sum digit position 4 1 great 8 rotate digit position 2 7 time rotate digit position 3 3 timesif digit position 4 great digit position 1 rotate digit position 2 3 time rotate digit position 3 2 timesif sum digit position 1 2 great 9 rotate digit position 3 6 time rotate digit position 5 3 timesif digit position 3 great digit position 2 rotate digit position 1 2 time rotate digit position 4 5 timesif digit position 5 great digit position 3 rotate digit position 2 1 time rotate digit position 4 5 timesif sum digit position 5 1 great 10 rotate digit position 4 7 time rotate digit position 3 5 timesif sum digit position 5 4 great 9 rotate digit position 3 9 time rotate digit position 2 4 timesif sum digit position 3 1 great 8 rotate digit position 2 8 time rotate digit position 4 4 timesif digit position 5 great digit position 2 rotate digit position 1 5 time rotate digit position 3 8 timesif sum digit position 1 4 great 10 rotate digit position 3 4 time rotate digit position 5 1 timesif digit position 3 great digit position 5 rotate digit position 2 1 time rotate digit position 1 6 timesif sum digit position 1 5 great 9 rotate digit position 3 3 time rotate digit position 2 1 timesif digit position 5 great digit position 1 rotate digit position 4 8 time rotate digit position 2 1 timesif digit position 4 great digit position 1 rotate digit position 3 4 time rotate digit position 5 4 timesif sum digit position 3 1 great 8 rotate digit position 5 3 time rotate digit position 2 6 timesif digit position 3 great digit position 4 rotate digit position 2 3 time rotate digit position 1 5 timesif digit position 5 great digit position 4 rotate digit position 2 7 time rotate digit position 3 8 timesif digit position 2 great digit position 4 rotate digit position 5 9 time rotate digit position 1 4 timesif sum digit position 3 5 great 10 rotate digit position 4 1 time rotate digit position 2 5 timesif digit position 4 great digit position 1 rotate digit position 3 9 time rotate digit position 2 9 timesif digit position 5 great digit position 3 rotate digit position 2 4 time rotate digit position 1 6 timesif sum digit position 3 4 great 9 rotate digit position 5 8 time rotate digit position 2 5 timesif sum digit position 3 4 great 10 rotate digit position 5 2 time rotate digit position 1 5 timesif sum digit position 5 4 great 9 rotate digit position 3 3 time rotate digit position 1 8 timesif digit position 5 great digit position 2 rotate digit position 1 4 time rotate digit position 3 8 timesif digit position 3 great digit position 1 rotate digit position 5 6 time rotate digit position 2 6 timesif digit position 4 great digit position 5 rotate digit position 1 6 time rotate digit position 3 1 timesif sum digit position 3 5 great 10 rotate digit position 2 5 time rotate digit position 1 7 timesif sum digit position 5 2 great 9 rotate digit position 4 9 time rotate digit position 3 5 timesif sum digit position 2 4 great 10 rotate digit position 3 1 time rotate digit position 1 2 timesif digit position 3 great digit position 4 rotate digit position 5 7 time rotate digit position 2 1 timesif digit position 2 great digit position 5 rotate digit position 1 6 time rotate digit position 4 2 timesif digit position 2 great digit position 1 rotate digit position 5 3 time rotate digit position 4 4 timesif digit position 5 great digit position 4 rotate digit position 3 9 time rotate digit position 1 9 timesif digit position 1 great digit position 5 rotate digit position 4 6 time rotate digit position 2 5 timesif sum digit position 1 5 great 10 rotate digit position 3 7 time rotate digit position 2 4 timesif sum digit position 2 1 great 9 rotate digit position 3 7 time rotate digit position 5 4 time
1graph
dark go attend motarack birthday Dark decide gift go Motarack array n nonnegative integersDark create array 1000 year ago element array disappear Dark know Motarack hate array adjacent element high absolute difference he do not time wants choose integer k 0 leq k leq 109 replace miss element array kLet m maximum absolute difference adjacent element ie maximum value a_i a_i1 1 leq leq n 1 array Dark replace miss element kDark choose integer k m minimize can help
1graph
GuyManuel Thomas plan 144 trip worldyou give simple weight undirected connect graph n vertex m edge follow restriction is not simple cycle e cycle do not pass vertex length great 3 pass vertex 1 the cost path necessarily simple graph define XOR weight edge path edge count times path pass itBut trip cost 0 are not exciting you choose subset edges incident vertex 1 remove how subset remove nontrivial cycle cost equal 0 pass vertex 1 result graph a cycle call nontrivial pass edge odd number time as answer big output modulo 1097
1graph
there n water tank row ith contain a_i liter water the tank number 1 n leave rightyou perform follow operation choose subsegment l r 1le l le r le n redistribute water tank l l1 dot r evenly in word replace a_l a_l1 dot a_r fraca_l a_l1 dot a_rrl1 for example volume 1 3 6 7 choose l 2 r 3 new volume water 1 45 45 7 you perform operation number timeswhat lexicographically small sequence volume water achieveas remindera sequence lexicographically small sequence b length following hold leftmost position b differ sequence small element correspond element b
1graph
this easy version problem the actual problem different easy version subtask hard version note constraint output format differentYou give string s consist n lowercase latin lettersyou color character color character exactly color letter color different color ie choose exactly color index sAfter color swap neighboring character stre color different color you perform operation arbitrary possibly zero number timesthe goal string sort ie character alphabetical orderyour task possible color give string color sorted sequence swap note restore color sequence swap
1graph
you give rectangular matrix size n time m consist integer 1 2 cdot 105in choose element matrix change value integer 1 n cdot m inclusive column shift cell cyclically example cyclic shift a cyclic shift operation choose j 1 le j le m set a_1 j a_2 j a_2 j a_3 j dot a_n j a_1 j simultaneously Example cyclic shift column you want perform minimum number move matrix look like in word goal obtain matrix a_1 1 1 a_1 2 2 dot a_1 m m a_2 1 m 1 a_2 2 m 2 dot a_n m n cdot m ie a_i j 1 cdot m j minimum number move perform
0array
SIHanatsuka EMber SIHanatsuka ATONEMENTBack time sevenyearold Nora play lot game creation robo_head02 fun enhance abilitiesone day Noras adoptive father Phoenix Wyle bring Nora n box toy before unpack Nora decide fun game ROBOShe label n box n distinct integer a_1 a_2 ldot a_n ask robo follow action possibly zero time pick distinct indice j k a_i mid a_j a_i mid a_k in word a_i divide a_j a_k a_j bmod a_i 0 a_k bmod a_i 0 after choose Nora kth box ROBO place box pile initially pile after box k unavailable action Being amuse different try game Nora ask robo calculate number possible different pile have large box two pile consider different exist position pile different boxessince robo infant stage Nora young concentrate long time fall asleep find final answer can help themas number pile large print answer modulo 109 7
2string
this easy version problem you find hard version Div 1 contest both version differ number time ask friend taste coffeethis interactive problemyoure consider move city friend live there n cafés city n power the ith café produce single variety coffee a_i as you re coffeelover decide want know number d distinct variety coffee produce cityyou do not know value a_1 ldot a_n fortunately friend memory size k k power twoOnce day ask taste cup coffee produce café c tell taste similar coffee k daysyou ask medication reset memory he forget previous cup coffee taste you reset memory 30 000 timesmore formally memory friend queue S do query café c tell a_c S add a_c S if S k pop element S do reset request pop element SYour friend taste dfrac2n2k cups coffee total Find diversity d number distinct value array aNote ask friend reset memory count number time ask friend taste cup coffeein test case behavior interactor adaptive it mean array fix start interaction depend query it guarantee moment interaction array consistent answer give far
1graph
you give n pairwise noncollinear twodimensional vector you shape twodimensional plane vector follow fashion Start origin 0 0 choose vector add segment vector current point for example current point x y choose vector u v draw segment current point point x u y v set current point x u y v Repeat step 2 reach origin againyou reuse vector time wantcount number different nondegenerate area great 0 convex shape apply step shape contain m time m square vector building shape counterclockwise fashion since number large calculate modulo 998244353two shape consider exist parallel translation shape anotherA shape contain m time m square exist parallel translation shape point u v inside border shape satisfie 0 leq u v leq m
1graph
there n lamp line number 1 n each initial state 0 1youre give k subset a_1 ldot a_k 1 2 dot n intersection subset in word 1 le i_1 i_2 i_3 le k A_i_1 cap A_i_2 cap A_i_3 varnothingIn operation choose k subset switch state lamp it guarantee give subset possible lamp simultaneously type operationlet m_i minimum number operation order lamp simultaneously note condition state lamp i1 n onYou compute m_i 1 le le n
2string
let string s t anagram possible rearrange symbol stre s string equal tLets consider string s t anagram we t reducible anagram s exist integer k ge 2 2k nonempty string s_1 t_1 s_2 t_2 dots s_k t_k satisfy follow condition if write string s_1 s_2 dot s_k order result string equal s if write string t_1 t_2 dots t_k order result string equal t for integer 1 k inclusive s_i t_i anagram if string do not exist t say irreducible anagram s note notion define s t anagram otherFor example consider stre s gamegame then stre t megamage reducible anagram s choose example s_1 game s_2 gam s_3 e t_1 mega t_2 mag t_3 e on hand prove t memegaga irreducible anagram sYou give stre s q query represent integer 1 le l le r le s s equal length string s for query find substre s form character lth rth irreducible anagram
1graph
you give n array a_1 a_2 a_n array consist exactly m integer we denote yth element xth array a_x yYou choose array a_i a_j 1 le j le n possible j after obtain new array b consist m integer k 1 m b_k maxa_i k a_j kYour goal choose j value min limits_k 1 m b_k maximum possible
1graph
its walking tour day SISWinter t group student visit Torzhok Streets Torzhok narrow student row anotherinitially student angry Lets describe group student string capital letter a p a correspond angry student p correspond patient student such string describe row studentevery minute angry student throw snowball student formally angry student correspond character index string describe group throw snowball student correspond character index i1 student give student if target student angry angry even rightmost string student angry do not throw snowball themlet look example test the row initially look like PPAP then minute single angry student throw snowball student angry PPAA after student angryyour task help siswinter teacher determine moment student angry group
2string
Fedya string S initially array W initially emptythere n query process time Query consist lowercase english letter c_i nonnegative integer w_i first c_i append S w_i append W the answer query sum suspiciousnesse subsegment W L R 1 leq L leq R leq iWe define suspiciousness subsegment follow substre S corresponding subsegment string consecutive character Lth Rth inclusive match prefix S length substring corresponding subsegment 1 R l 1 suspiciousness equal minimum array W L R subsegment Otherwise case substre match correspond prefix suspiciousness 0help Fedya answer query orderly come
1graph
Evlampiy gift rooted tree the vertex tree number 1 n each vertex integer a_i write for vertex Evlampiy calculate c_i number vertice j subtree vertex a_j a_i illustration second example integer a_i integer parenthese c_iafter new year Evlampiy remember gift he remember tree value c_i completely forgot integer a_i write verticeshelp restore initial integer
2string
give array consist n integer findmaxlimits_1 le j le n LCMa_ia_jwhere LCMx y small positive integer divisible x y for example LCM6 8 24 LCM4 12 12 LCM2 3 6
1graph
today friendship gift Bakry give Badawy n integer a_1 a_2 dot a_n challenge choose integer x value underset1 leq leq nmax a_i oplus X minimum possible oplus denote bitwise XOR operationAs Badawy lazy decide help find minimum possible value underset1 leq leq nmax a_i oplus x
1graph
fill optimism Hyunuk host conference great new year beThe conference n lecture Hyunuk candidate venue b for n lecture speaker specify time interval sa_i ea_i sa_i le ea_i sb_i eb_i sb_i le eb_i if conference situate venue lecture hold sa_i ea_i conference situate venue b lecture hold sb_i eb_i Hyunuk choose venue lecture hold venueTwo lecture say overlap share point time common Formally lecture hold interval x y overlaps lecture hold interval u v maxx u le miny vWe participant attend subset s lecture lecture s pairwise overlap ie lecture overlap note possibility attend depend Hyunuk select venue venue b hold conferenceA subset lecture s say venuesensitive venue participant attend s venue participant attend sA venuesensitive set problematic participant interested attend lecture s participant sure lecture time overlap Hyunuk happy venuesensitive set Determine Hyunuk happy
1graph
happy new year the year 2020 know Year Gyeongja 경자년 gyeongjanyeon Korea where come Lets briefly look Gapja system traditionally Korea yearsThere sequences n string s_1 s_2 s_3 ldot s_n m string t_1 t_2 t_3 ldot t_m these string contain lowercase letter there duplicate stringslet concatenation string x y string obtain write string x y right change order for example concatenation string code force stre codeforcesThe year 1 concatenation string s_1 t_1 when year increase concatenate string order respective sequence if stre currently end sequence string sequenceFor example n 3 m 4 s b c t d e f g follow table denote result year name Note name year repeat you give sequence string size n m q query for query give current year could find corresponding give year accord Gapja system
2string
oh New Year the time gather friend reflect heartwarme event past yearn friend live city represent number line the ith friend live house integer coordinate x_i the ith friend come celebrate New Year house coordinate x_i1 x_i1 stay x_i each friend allow oncefor friend 1 le x_i le n hold come house coordinate 0 n1 house 1 n respectivelyfor example let initial position x 1 2 4 4 the final one 1 3 3 4 0 2 3 3 2 2 5 5 2 1 3 5 the number occupy house number distinct position final onesSo friend choose move want perform after number occupy house calculate what minimum maximum number occupy house
2string
this interactive problemafter complete level enchant temple receive powerful artifact 255th level do rush celebrate artifact powerful rune destroy single spell s go find we define spell nonempty string consist letter bat time cast arbitrary nonempty spell t rune artifact begin resist Resistance rune edit distance string specify casted spell t runedestroying spell sedit distance string s t value equal minimum number onecharacter operation replace insert delete character s t for example distance ababa aaa 2 distance aaa aba 1 distance bbaba abb 3 the edit distance 0 string equalIt worth consider artifact resistance limit cast n 2 spell n length spell s rune blockedthu take n 2 few spell destroy rune artifact Keep mind require destructive spell s count n 2 spellsnote length n runedestroye spell s know advance it know length n exceed 300
1graph
you allpowerful create rectangular world in fact world bland represent r time c grid each cell grid represent country each country dominant religion there religion world one religion call Beingawesomeism good sake good the religion call pushingittoofarism murder sake badOh actually allpowerful you power use infinitely time your power involve missionary group when missionary group certain country pass country b change dominant religion country b dominant religion country ain particular single use power you choose horizontal 1 time x subgrid vertical x times 1 subgrid that value x you choose direction d if choose horizontal subgrid choice NORTH south if choose vertical subgrid choice EAST WEST you choose number s step you command country subgrid send missionary group travel s step direction d in step visit effect convert dominant religion s country pass detailed the parameter x d s choose way missionary group will not leave grid the following image illustrate possible single usage power here a represent country dominant religion Beingawesomeism P represent country dominant religion Pushingittoofarism here we ve choose 1 time 4 subgrid direction NORTH s 2 step you believe free however want stop receive murder attribute hence decide use power try Beingawesomeism dominant religion countrywhat minimum number usage power need convert BeingawesomeismWith god impossible but maybe you re god if impossible Beingawesomeism dominant religion country admit mortality
1graph
Santa send present kid he large stack n present number 1 n topmost present number a_1 present a_2 present number a_n all number distinctsanta list m distinct present send b_1 b_2 b_m he send order appear listto send present Santa find stack remove present take present returning remove present stack so k present present Santa want send take 2k 1 second fortunately Santa speed process return present stack reorder wish present want present affect waywhat minimum time require send present provide Santa know list present send reorder present optimally Santa change order present interact stack present wayYour program answer t different test case
1graph
New Year come Vasya prepare New Years verse want recite Santa ClausVasyas verse contain n part it take a_i second recite ith Vasya can not change order part verse firstly recite take a_1 second secondly take a_2 second after recite verse Vasya number present equal number part fully recitedvasya skip verse recite skip Santa definitely notice itSanta listen Vasyas verse s second for example s 10 100 9 1 1 Vasya skip verse get presentsnote possible recite verse time Determine Vasya need skip obtain maximum possible number gift if Vasya should not skip print 0 if multiple answer print themyou process t test case
1graph
you give n integer you need choose subset choose number beautiful rectangle rectangular matrix each choose number occupy rectangle cell cell fill exactly choose number some n number chosena rectangle rectangular matrix call beautiful row column value differentwhat large total number cell beautiful rectangle construct Print rectangle
1graph