question
stringlengths
58
4.29k
label
class label
3 classes
in generation choose one she stand vampire demon force darkness she Slayer Joss Whedon
1graph
you give circular maze one show figure Determine solve ie path go center outside maze touch wall the maze describe n wall each wall circular straight circular wall describe radius r distance center angle theta_1 theta_2 describe begin end wall clockwise direction Notice swapping angle change wall Straight wall describe angle theta direction wall radii r_1 r_2 describe begin end wall Angles measured degree angle 0 correspond upward point direction angle increase clockwise east direction correspond angle 90
1graph
gianni swerc chief judge receive huge high quality problem judge choose problem set SWERCHe receive n problem assign beauty score difficulty the ith problem beauty score equal b_i difficulty equal d_i the beauty difficulty integer 1 10 if problem certain difficulty possible difficulty 12dots10 Gianni ask problem judgesotherwise difficulty 1 10 problem set beautiful problem difficulty problem set contain exactly 10 problem distinct difficulty you shall compute total beauty problem set sum beauty score problem choose Gianni
1graph
not long ago vlad birthday present package candy there n type candy a_i candy type 1 le le nVlad decide eat exactly candy time choose candy type currently frequent type choose to maximum pleasure eat Vlad want eat candy type rowhelp figure eat candy eat identical candy row
0array
Team Red Team Blue compete competitive FPS their match stream world they play series n matchesIn end turn Team Red win r time Team Blue win b time Team Blue skilled Team Red b strictly ryou miss stream overslept think match neck neck people watch so imagine string length n ith character denote win ith match R Team Red win B Team Blue win you imagine stre maximum number time team win row small possible for example series match RBBRRRB Team Red win 3 time row maximumyou find string satisfy condition if multiple answer print
2string
Marin want count number permutation beautiful a beautiful permutation length n permutation follow property gcd 1 cdot p_1 2 cdot p_2 dot n cdot p_n 1 gcd great common divisorA permutation array consist n distinct integer 1 n arbitrary order for example 23154 permutation 122 permutation 2 appear twice array 13 4 permutation n3 4 array
1graph
in problem consider complete undirected graph consist n vertex weight edge the weight edge integer 1 kAn undirected graph consider beautiful sum weight edge incident vertex 1 equal weight mst graph mst minimum span tree tree consist n1 edge graph connect n vertex minimum sum weight tree weight MST sum weight edge itcalculate number complete beautiful graph have exactly n vertex weight edge 1 k since answer large print modulo 998244353
1graph
you give integer n b x y you build sequence a_0 a_1 a_2 dot a_n a_0 0 ge 1 choose a_i a_i 1 x a_i a_i 1 y your goal build sequence a_i le B sumlimits_i0na_i maximum possible
2string
there s chip point 0 0 coordinate plane in operation chip point x_1 y_1 point x_2 y_2 euclidean distance point integer ie sqrtx_1x_22y_1y_22 integerYour task determine minimum number operation require chip point 0 0 point x y
1graph
you give n integer a_1 a_2 ldot a_n for real number t consider complete weighted graph n vertex K_nt weight edge vertex j equal w_ijt a_i cdot a_j t cdot a_i a_j let ft cost minimum span tree K_nt Determine ft bound output maximum value attain
1graph
you give array a_1 a_2 ldot a_n positive integer a good pair pair index j 1 leq j leq n 1 leq k leq n follow equality hold a_i a_k a_k a_j a_i a_j x denote absolute value xFind good pair note equal j
2string
there n location snowy mountain range number 1 n connect n1 trail shape tree each trail length 1 some location base lodge the height h_i location equal distance near base lodge base lodge height 0there skier location skier initial kinetic energy 0 each skier want ski trail possible suppose skier skiing trail location j Skiers allow ski uphill ie h_i h_j it cost unit kinetic energy ski flat ground ie h_i h_j skier gain unit kinetic energy ski downhill ie h_i h_j for location compute length long sequence trail skier start location ski kinetic energy negative skier allow visit location trail multiple time
1graph
Alice cake going cut she perform follow operation n1 time choose piece cake initially cake piece weight wge 2 cut small piece weight lfloorfracw2rfloor lceilfracw2rceil lfloor x rfloor lceil x rceil denote floor ceiling function respectivelyafter cut cake n piece line n piece table arbitrary order let a_i weight ith piece lineyou give array Determine exist initial weight sequence operation result
2string
there n piece cake line the ith piece cake weight a_i 1 leq leq nThe tastiness cake maximum total weight adjacent piece cake ie maxa_1a_2 a_2a_3 ldot a_n1 a_nyou want maximize tastiness cake you allow follow operation operation ruin cake Choose contiguous subsegment al r piece cake 1 leq l leq r leq n reverse the subsegment al r array sequence a_l a_l1 dot a_rif reverse array a_1 a_2 dots a_l2 a_l1 underlinea_r underlinea_r1 underlinedot underlinea_l1 underlinea_l a_r1 a_r2 dot a_n1 a_nfor example weight initially 5 2 1 4 7 3 reverse subsegment a2 5 get 5 underline7 underline4 underline1 underline2 3 the tastiness cake 5 7 12 operation tastiness 4711find maximum tastiness cake operation
1graph
let denote size maximum match graph g mathitmmgyou give bipartite graph the vertex number 1 n vertex second number n1 2n each vertexs degree 2for tuple integer l r L R 1 le l le r le n n1 le L le R le 2n let define Gl r L R graph consist vertex give graph include segment l r segment L R edge give graph endpoint belong segment in word obtain Gl r L R original graph remove vertex notin l r notin L R edge incident verticesCalculate sum mathitMMGl r L R tuple integer l r l R have 1 le l le r le n n1 le L le R le 2n
1graph
now Dmitry session pass n exam the session start day 1 last d day the ith exam place day a_i 1 le a_i le d a_i different Sample n3 d12 a359 Orange exam day before exam Dmitry rest 2 day second rest 1 day rest 3 day for session schedule Dmitry consider special value mu small rest time exam exam for example image mu1 in word schedule count exactly n number day rest exam i1 i0 start session exam then find mu minimum n numbersdmitry believe improve schedule session he ask change date exam change arbitrary value a_i help change date a_i remain different value mu large possiblefor example schedule advantageous Dmitry second exam end session the new schedule form now rest period exam equal 225 so mu2 Dmitry leave propose schedule unchanged way exam lead improvement situation
1graph
not long ago Vlad come interesting function f_axleftlfloorfracxarightrfloor x bmod leftlfloorfracxarightrfloor fracxa rounded x bmod remainder integer division x aFor example a3 x11 value f_311 leftlfloorfrac113rightrfloor 11 bmod 3 3 2 5the number fix know Vlad Help Vlad find maximum value f_ax x integer value l r inclusive l le x le r
2string
Daniel watch football team play game training session they want improve pass skill sessionthe game involve n player make multiple pass unfortunately ball move fast session Daniel unable know ball involve game the thing know number pass deliver player sessionfind minimum possible ball involve game
2string
you give array n positive integer number 1 n Lets array integral necessarily different number x y array x ge y number leave lfloor fracxy right rfloor x divide y round arrayyou guarantee number exceed c your task check array integral
1graph
a number call powerful power factorial in word number m powerful exist nonnegative integer d m2d md d1cdot 2cdot ldot cdot d particular 0 1 for example 1 4 6 powerful number 11 422 63 7 10 18 notyou give positive integer n find minimum number k n represent sum k distinct powerful number k
1graph
there sheet paper represent grid size n time m n row m column cell all cell color white initiallyq operation apply sheet the ith describe follow x_i y_i choose k nonwhite color color entire row x_i entire column y_i the new color apply cell regardless cell color operation the sheet apply q operation call color two coloring different exist cell color different colorshow different coloring print number modulo 998244353
1graph
you give array a_1 a_2 dot a_n consist n integer you give integer value xLet fk maximum sum contiguous subarray apply follow operation add x element exactly k distinct position an subarray consider sum 0Note subarray do not include increase elementsCalculate maximum value fk k 0 n independently
1graph
all problem contest share statement difference test solution run for information scoring refer scoring section statementThis interactive problemimagine treasure hunter skillful one day come ancient map help rich the map show multiple forestry road junction treasure so start journey hope retrieve hide treasure do not know wicked wizard standing craving tangle road impede achievementsthe treasure map represent undirected graph vertex correspond junction edge correspond road your path begin certain fix vertex label know every time come vertex dig treasure chest flag vertex at initial vertex you ll find treasure chest immediately consequently you ll flag immediately wellwhen stand junction adjacent vertex degree flag there thing besides power wicke wizard great able change location road junction map change graph structure therefore sequence road come junction v different time come junction v however mind set adjacent crossroad change aware previously dig treasure adjacent v vertexyour goal collect treasure vertex graph fast good luck hunt
1graph
you give array a_1 a_2 dot a_n you perform operation array in operation choose integer 1 le n swap element a_i a_i1 array a_i a_i1 odddetermine sort nondecrease order operation number time
0array
Andrew n pile stone the ith pile contain a_i stone he want table clean decide stone 1st nth pileAndrew perform follow operation number time choose 3 index 1 le j k le n jth pile contain 2 stone take 2 stone pile j put stone pile stone pile k tell Andrew minimum number operation need stone pile 1 n determine impossible
2string
you give array n element your perform follow operation n time Select index xyz 1 leq x y z leq n replace a_x a_y a_z after operation a_x need 1018your goal result array nondecrease if multiple solution output if impossible achieve report
1graph
one productive day throw away 1000 line code Ken ThompsonFibonacci addition operation array x integer parametrize indice l r Fibonacci addition increase x_l f_1 increase x_l 1 F_2 X_r increase F_r l 1f_i denote ith Fibonacci number f_1 1 f_2 1 f_i f_i 1 f_i 2 2 operation perform modulo MODYou give array a b length we ask perform Fibonacci addition array different parameter operation report array a b equal modulo MOD
1graph
People worry computer smart world real problem they re stupid they ve take world Pedro DomingosYou work wellknown department store use lead technology employ mechanistic work robotsThe department work sell n cdot k item the item cost 1 dollar second item cost 2 dollar ith item cost dollar the item situate shelf the item form rectangular grid n shelf total shelf contain exactly k item we denote a_ij price jth item counting leave ith shelf 1 le le n 1 le j le kOccasionally robot curious ponder follow question mean price arithmetic average item a_il a_il1 ldot a_ir shelf indice l le r unfortunately old robot work number if mean price turn integer break downyou care robot welfare you want arrange item way robot theoretically break Formally want choose twodimensional array every number 1 n cdot k inclusively occur exactly for l r mean price item l r ith shelf integer find arrangement possible example arrangement
2string
Haha try solve SelectorUnlimited antontrygubo_oyour friend Alice Bob practice fortune tellingFortune tell perform follow there wellknown array n nonnegative integer index 1 n the tellee start nonnegative number d perform operation 1 2 ldot n increase order the possible operation replace current number d d a_i replace current number d d oplus a_i hereinafter oplus denote bitwise XOR operationnotice choose operation different different different telleesone time Alice decide start d x Bob start d x 3 each perform fortune telling get particular number end Notice friend choose operation independently apply different operation iYou learn Alice Bob end number y end do not know give number Alice Bob start y find Alice Bob number y perform operation it guarantee jury test exactly friend actually get numberhacksyou hack problem
1graph
you array integer size n Initially element array equal 1 you perform follow operation choose integer 1 le le n x x 0 increase value a_i leftlfloorfraca_ixrightrfloor ie a_i a_i leftlfloorfraca_ixrightrfloorafter perform operation receive c_i coin a_i b_iyour task determine maximum number coin receive perform k operation
1graph
this version problem differ constraint na tree connect undirected graph cycle a weight tree weight assign edge the distance vertice minimum sum weight path connect themyou give weight tree n vertex edge weight 1 Denote dv distance vertex 1 vertex vLet fx minimum possible value maxlimits_1 leq v leq n dv temporarily add edge weight x vertex b 1 le b le n Note operation graph long treefor integer x 1 n find fx
2string
igor 11th grade tomorrow write informatic test strict teacher school Pavel Denisovich Igor know test conduct teacher student positive integer b b after student apply follow operation number times 1 increase 1 b b 1 increase b 1 b replace bitwise or b to mark test student tell teacher minimum require number operation b equaligor know number teacher help figure minimum number operation need equal b
1graph
you give array b n positive integer you apply follow operation number time Select index 1leq ileq n swap a_i b_i ie a_i b_i vice versa find minimum possible value maxa_1 a_2 ldot a_n cdot maxb_1 b_2 ldot b_n apply operation number time possibly zero
2string
give cyclic array size n a_i value ith position repeat value let define permutation equal permutation value position transform perform cyclic rotation let define cyclic array b number component number connect component graph vertex position b add edge pair adjacent position b equal value note cyclic array position adjacentsFind expect value component permutation select equiprobably set different permutation
1graph
you give n element number 1 n element value a_i color c_i initially c_i 0 ithe follow operation apply Select element j k 1 leq j k leq n c_i c_j c_k equal 0 a_i a_k set c_j 1 find maximum value sumlimits_i1nc_i obtain apply give operation number time
1graph
this hard version problem the difference constraint n m t you hack version problem solvedAlice Bob give number n m k play game followsThe game score Alice try maximize Bob tries minimize the score initially 0 the game consist n turn each turn Alice pick real number 0 k inclusive Bob add subtract score game but game Bob choose add m n turnsbob get know number Alice pick decide add subtract number score Alice get know Bob add subtract number previous turn pick number current turn turn previous turnif Alice Bob play optimally final score game
1graph
Mihai plan watch movie he like palindromic movie wants skip possibly zero scene remain part movie palindromicYou give list s n nonempty string length 3 represent scene Mihais movieA subsequence s call awesome nonempty concatenation string subsequence order palindromecan help Mihai check awesome subsequence sA palindrome string read backward forward example string z aaa aba abccba palindromes string codeforce reality ab nota sequence nonempty subsequence nonempty sequence b obtain b deletion possibly zero element
2string
there k time k grid k the square row r column c denote rc two square r_1 c_1 r_2 c_2 consider adjacent lvert r_1 r_2 rvert lvert c_1 c_2 rvert 1an array adjacent pair square call strong possible cut grid grid line connect congruent piece pair piece two piece congruent match translation rotation reflection combination the picture represent test case arrow indicate pair square thick black line represents cut you give array n pair adjacent square find size large strong subsequence an array p subsequence array q p obtain q deletion possibly zero element
2string
you give integer array a_0 a_1 dot a_n 1 integer k you perform follow code itlong long ans 0 create 64bit sign variable initially equal 0forint 1 k int idx rndnext0 n 1 generate random integer 0 n 1 inclusive integer 0 n 1 probability choose an aidx aidx aidx iYour task calculate expect value variable an perform codenote input generate accord special rule input format section
1graph
martian scientist explore Ganymede Jupiters numerous moon recently find ruin ancient civilization the scientist bring Mars tablet writing language unknown sciencethey find inhabitant Ganymede alphabet consist letter word exactly ell letter long so scientist decide write word language integer 0 2ell 1 inclusively the letter alphabet correspond zero bit integer second letter correspond bitthe word form language then need restore initial form the process describe belowdenote distance word position word differ for example distance 1001_2 1100_2 binary equal word different letter second fourth position count leave right far denote distance word x y dx yLet word n form ith describe integer x_i all x_i necessarily different form word write consider word y then closeness word y equal sum distance word form ie sum dx_i y 1 le le nThe initial form word y minimal possible nearnessyou need help scientist write program find initial form word give know form note initial form necessarily equal n give form
1graph
you give array consist n positive integer you perform operation itIn operation replace element array a_i lfloor fraca_i2 rfloor integer divide a_i 2 round downsee apply operation number time possible 0 array permutation number 1 nthat contain number 1 n exactly oncefor example 1 8 25 2 n 4 answer yes you follow replace 8 lfloor frac82 rfloor 4 1 4 25 2 replace 25 lfloor frac252 rfloor 12 1 4 12 2 replace 12 lfloor frac122 rfloor 6 1 4 6 2 replace 6 lfloor frac62 rfloor 3 1 4 3 2
1graph
polycarp 3 positive integer b c he perform follow operation exactly choose positive integer m multiply exactly integer b c m can polycarp perform operation sequence number b c order form arithmetic progression note change order b cFormally sequence x_1 x_2 dot x_n call arithmetic progression AP exist number d call common difference x_i1x_id 1 n1 in problem n3for example follow sequence AP 5 10 15 3 2 1 1 1 1 13 10 7 the follow sequence AP 1 2 4 0 1 0 1 3 2you need answer t independent test case
1graph
railway network city consist n station connect n1 road these station road form tree Station 1 city center for road know time train spend pass road you assume train do not spend time stop Lets define distv time train spend station v station 1this railway network splitte zone name k capital latin letter the zone ith station z_i city center zone a for station guarantee station road station city center zone zone lexicographically small any road completely own zone distant end city centertourist arrive airport soon city center Heres trip station v station 1 happend at moment 0 tourist enter train follow directly station v station 1 the trip distv minute tourist buy ticket subset zone moment ticket zone cost pass_i euro every t minute start trip moment t 2 t ldot control system scan tourist if moment scan tourist zone zone ticket pay fine_i euro Formally zone tourist determine follow way if tourist station 1 city center should not pay fine if tourist station u neq 1 zone z_u if tourist move station x station y directly connect road zone z_x note tourist pay fine multiple time zone Tourist select way buy ticket pay fine minimize total cost trip let fv cost station vUnfortunately tourist do not know current value pass_i fine_i different zone forget location airport he ask query 3 type 1 c cost ticket zone change now pass_i c 2 c cost fine zone change now fine_i c 3 u solve follow problem current value pass fine you give station u consider station v satisfy follow condition z_v z_u the station u path station v station 1 Find value minfv station v follow assumption tourist ticket zone station z_u
1graph
you give integer k string s consist character lowercase latin letter asteriskeach asterisk replace 0 k inclusive lowercase Latin letter b different asterisk replace different count letter bThe result replacement call BAstringTwo string b different different length exist position a_i neq b_iA stre lexicographically small string b follow hold prefix b ne b position b differ string letter appear early alphabet corresponding letter b now consider different BAstrings find xth lexicographically smallest
0array
Vlad n friend want buy gift New YearThere m shop city buy gift friend if jth friend 1 le j le n receive gift buy shop number 1 le le m friend receive p_ij unit joy the rectangular table p_ij give inputvlad time visit n1 shop n number friend he choose shop visit friend buy gift themlet jth friend receive a_j unit joy Vlads gift Lets find value alphamina_1 a_2 dot a_n vlad goal buy gift value alpha large possible in word vlad wants maximize minimum joy friendsfor example let m 2 n 2 let joy gift buy shop p_11 1 p_122 second shop p_21 3 p_224then Vlad second shop buy gift friend bring joy 3 second bring joy 4 in case value alpha equal min3 4 3help Vlad choose gift friend value alpha high possible please note friend receive gift Vlad visit n1 shop n number friend in shop buy number gift
2string
n town arrange circle sequentially the town number 1 n clockwise order in ith town live singer repertoire a_i minute 1 nEach singer visit n town clockwise order start town life give exactly concert town in addition town ith singer got inspire come song last a_i minute the song add repertoire perform rest citieshence ith singer concert ith town a_i minute 1th town concert 2 cdot a_i minute k bmod n 1th town duration concert k 2 cdot a_i town n 2 bmod n 1 n cdot a_i minutesYou give array b integer number b_i total duration concert ith town Reconstruct correct sequence positive integer impossible
1graph
Polycarp come new game play he call a miss bigramA bigram word sequence adjacent letter itFor example word abbaaba contain bigrams ab bb ba aa ab baThe game go follow First Polycarp come word consist lowercase letter b then write bigrams whiteboard order appear word after wipe whiteboardfinally Polycarp invite guess word come wasyour goal find word possible write bigrams remove result sequence bigrams Polycarp end withthe test generate way answer exist if multiple answer print
1graph
this interactive problem the difference easy hard version limit number questionsThere n player label 1 n it guarantee n multiple 3among k impostor nk crewmate the number impostor k give it guarantee fracn3 k frac2n3In question choose distinct integer b c 1 le b c le n ask among player label b c impostor crewmate you give integer 0 impostor crewmate 1 otherwisefind number impostor k index player impostor ask n6 questionsThe jury adaptive mean index impostor fix depend question it guarantee set impostor fulfill constraint answer question time
2string
this interactive problem the difference easy hard version limit number questionsThere n player label 1 n it guarantee n multiple 3among k impostor nk crewmate the number impostor k give it guarantee fracn3 k frac2n3In question choose distinct integer b c 1 le b c le n ask among player label b c impostor crewmate you give integer 0 impostor crewmate 1 otherwisefind number impostor k index player impostor ask 2n questionsThe jury adaptive mean index impostor fix depend question it guarantee set impostor fulfill constraint answer question time
1graph
you give array a_1 a_2 ldot a_n integer xFind number nonempty subset index array 1 leq b_1 b_2 ldots b_k leq n pair j 1 leq j leq k inequality a_b_i oplus a_b_j leq x hold here oplus denote bitwise XOR operation as answer large output modulo 998244353
1graph
an array a_1 a_2 ldot a_n good subsegment 1 leq l leq r leq n follow hold a_l a_l 1 ldot a_r frac12a_l a_r cdot r l 1 you give array integer a_1 a_2 ldot a_n in operation replace element array real number find minimum number operation need array good
2string
you give n integer a_1 a_2 ldot a_n you choose subset give number possibly number negate number ie change x x what maximum number different value array achieve
1graph
two player Red Blue time they re play crayon the mischievous duo vandalizing root tree coloring node play favorite gameThe game work follow tree size n root node 1 node initially white Red Blue turn Red go in Reds turn follow operation number time Pick subtree root tree color node subtree red However game fair Red allow color k node tree in word Reds turn k node color redthen Blues turn Blue follow operation number time Pick subtree root tree color node subtree blue however he s allow choose subtree contain node color red node purple like purple crayon note there s restriction number nod blue color long do not color node Red coloredafter turn score game determine follow let w number white node r number red node b number blue node the score game w cdot r bRed want maximize score Blue want minimize if player play optimally final score game
2string
there n candle Hanukkah menorah candle initially light we describe candle light binary string s ith candle light s_i1 initially candle light describe string in operation select candle currently light by candle select remain light candle change light unlit unlit lityou like candle look stre b your task determine possible find minimum number operation require
1graph
there n block tower row tower height a_i you re build crew want building look nice possible in single day perform follow operation Choose indice j 1 leq j leq n neq j block tower tower j this essentially decrease a_i 1 increase a_j 1 you think ugliness building height difference tall short building Formally ugliness define maxamina what s minimum possible ugliness achieve number day
1graph
you give rooted tree consist n vertex number 1 n the root tree vertex 1you color vertex tree n color number 1 n exactly vertex color let c_i color vertex p_i parent vertex root tree the coloring consider beautiful vertex k k 1 c_k c_p_k 1 ie vertex color color parent exactly 1calculate number beautiful coloring print modulo 998244353
1graph
monocarp playing computer game in game character kill dragon the battle dragon last 100500 second Monocarp attack dragon poison dagger the ith attack perform begin a_ith second battle start the dagger deal damage apply poison effect dragon deal 1 damage k second start second dragon stab dagger however dragon poison dagger update poison effect ie cancel current poison effect apply new oneFor example suppose k 4 Monocarp stab dragon second 2 4 10 then poison effect apply start 2nd second deal 1 damage 2nd 3rd second begin 4th second poison effect reapplie deal exactly 1 damage second 4 5 6 7 10th second poison effect apply deal 1 damage second 10 11 12 13 in total dragon receive 10 damagemonocarp know dragon h hit point deal h damage dragon battle slay dragon Monocarp decide strength poison use battle wants find minimum possible value k number second poison effect last deal h damage dragon
2string
monocarp write number whiteboard both number follow specific format positive integer x p zero append endnow Monocarp ask compare number can help
2string
a permutation length n array pp_1p_2dot p_n contain integer 1 n inclusive exactly for example p4 2 6 5 3 1 permutation length 6you give integer n b n number print permutation length n minimum element leave half equal maximum element right half equal b print 1 permutation exist
1graph
after watch new overrated series Squid Game Mashtali Soroush decide hold Squid Games Soroush agree host provide money winner prize Mashtali Front Manm player register play game win great prize Mashtali find huge winner prize going decide kill eliminate player money himselfHere evil Mashtali go eliminate playersThere unrooted tree n vertex every player 2 special vertex x_i y_iin operation Mashtali choose vertex v tree then remain player find vertex w simple path x_i y_i close v if wne x_i wne y_i player eliminatedNow Mashtali wonder what minimum number operation I perform I remove player game money myselfsince think money could not solve problem ask help
1graph
Keshi throw party want everybody party happyhe n friend his ith friend dollar if invite ith friend party happy a_i people party strictly rich b_i people strictly poor himKeshi want invite people possible find maximum number people invite party invite person happy
1graph
an array b_1 b_2 ldot b_m palindrome b_i b_m1i 1 m empty array palindromeAn array call kalindrome follow condition hold its possible select integer x delete element array equal x remain array glue remain part palindrome Note do not delete element equal x do not delete element equal xFor example 1 2 1 kalindrome simply delete single element 3 1 2 3 1 kalindrome choose x 3 delete element equal 3 obtain array 1 2 1 palindrome 1 2 3 kalindrome you give array a_1 a_2 ldot a_n determine kalindrome
1graph
n player play game there different map game for player know strength map when player fight specific map player high strength map win no player strength map you game master want organize tournament there total n1 battle while player tournament choose map remain player fight the player lose eliminate tournament in end exactly player remain declare winner tournament for player determine win tournament
1graph
there n hero fight arena initially ith hero a_i health pointsthe fight arena take place round at begin round alive hero deal 1 damage hero hit hero occur simultaneously heroe health 1 end round consider killedIf exactly 1 hero remain alive certain round declare winner otherwise winnerYour task calculate number way choose initial health point hero a_i 1 le a_i le x winner fight the number way large print modulo 998244353 two way consider different hero different health for example 1 2 1 2 1 1 different
0array
Eikooc Sushi play gamethe game play tree having n node number 1 n Recall tree having n node undirecte connect graph n1 edgesthey turn alternately move token tree Eikooc make place token node choice Sushi make follow Eikooc follow Sushi in turn player token node u u adjacent node v token currently u visit u oplus v leq minu v here x oplus y denote bitwise XOR operation integer x yBoth player play optimally the player unable losesthe follow example demonstrate rule game suppose Eikooc start game place token node 4 Sushi move token node 6 unvisited adjacent 4 it hold 6 oplus 4 2 leq min6 4 in turn Eikooc move token node 5 unvisited adjacent 6 it hold 5 oplus 6 3 leq min5 6 Sushi move play lose suppose Eikooc start game place token node 3 Sushi move token node 2 unvisited adjacent 3 it hold 3 oplus 2 1 leq min3 2 Eikooc token node 6 6 oplus 2 4 nleq min6 2 since Eikooc move play lose before game begin Eikooc decide sneakily relabel node tree favour formally relabele permutation p length n sequence n integer integer 1 n occur exactly p_i denote new number node iShe want maximize number node choose turn guarantee win help Eikooc find relabele help
2string
it October 18 2017 Shohag melancholic soul strong determination pursue Competitive Programming seriously heart find fascinating Fast forward 4 year happy take road he create contest codeforce he find astounding problem idea solve help solve final problem roundyou give integer n k x Find number modulo 998244353 integer sequence a_1 a_2 ldot a_n follow condition satisfy 0 le a_i lt 2k integer 1 n there nonempty subsequence bitwise XOR element subsequence x a sequence b subsequence sequence c b obtain c deletion possibly zero element
1graph
for array b n integer extreme value array minimum number time possibly zero follow operation perform b nondecrease Select index 1 le le b b current length b replace b_i element x y x y positive integer x y b_i this way array b change operation perform modified array for example b 2 4 3 index 2 gets select possible array operation 2 underline1 underline3 3 2 underline2 underline2 3 2 underline3 underline1 3 and consequently array single operation nondecrease 2 4 3 rightarrow 2 underline2 underline2 3its easy array positive integer nondecrease wayyoukn0wwho array n integer help find sum extreme value nonempty subarray modulo 998244353 if subarray appear multiple time extreme value count number time appearsan array d subarray array c d obtain c deletion possibly zero element begin possibly zero element end
1graph
black gift Divine array consist n 1 le n le 2000 integer each position initial value after shout curse array angry start unstoppable transformationthe transformation consist infinite step Array change ith step follow way position j a_j equal number occurrence a_j start stephere example help understand process well initial array2 1 1 4 3 1 2after 1st step2 3 3 1 1 3 2after 2nd step2 3 3 2 2 3 2after 3rd step4 3 3 4 4 3 4 in initial array 2s 1s 4 3 step element equal number occurrence initial array two change 2 one change 3 change 1 change 1the transformation step continue foreveryou process q query query Black curious know value a_x kth step transformation
2string
you give string s you need find nonempty string b follow condition satisfy Strings b subsequence s for index character s_i string s belong exactly string b String lexicographically minimum possible string b possible string give stre s print valid bReminderA string b subsequence string s b obtain s deletion possibly zero element for example dore cf subsequence codeforce decor fork nota string x lexicographically small string y follow hold x prefix y x ne y position x y differ string x letter appear early alphabet corresponding letter y
1graph
you give array integer a_1 a_2 ldot a_n b_1 b_2 ldot b_myou need insert elements b arbitrary way as result array c_1 c_2 ldot c_nm size n mNote allow change order element insert elements b arbitrary position they insert begin element end Moreover element b appear result array orderwhat minimum possible number inversion result array c recall inversion pair indice j j c_i c_j
1graph
Alice Bob playing game they give array a length N the array consist integer they build sequence in begin sequence in turn player remove number leave right array append sequence the rule sequence building strictly increase the winner player make Alice play give start array assumption play optimally win game
2string
you give undirected graph N node M edge e_1 e_2 dot e_ma connect graph cactus edge belog simple cycle a graph desert connect component cactus find number pair L R 1 leq L leq R leq M delete edge e_l e_l1 dot e_r graph desert
1graph
you give integer array length N A1 A2 you give Q query 4 type 1 k l r x set Ak_iminAk_i x l leq leq r2 k l r x set ak_imaxak_i x l leq leq r3 k l r x set Ak_iAk_ix l leq leq r4 l r find sum_ilr fa1_ia2_i 1097 Fk kth Fibonacci number F00 F11 FkFk1Fk2 x y denote remainder division x yYou process query answer query fourth type
2string
little Johnny Bubbles enjoy spending hour computer play video game his favorite game bubble Strike fastpace bubble shoot online game playerseach game set n map have different terrain configuration first phase game decide map game play the game system randomly select map show player each player pick map discard the game system randomly select map pick player start gameJohnny deeply enthusiastic game wants spend time study map increase chance win game play map however need homework time study map that ask follow question what minimum number map I study probability play map PCan help Johnny find answer question you assume Johnnys opponent know randomly pick map
1graph
you give array a length N weight mass a_1 a_2a_nno weight mass you weight balance leave rightYoudont putweightsin order a_1a_nthere astre Sconsisting character l rmeane put theithweight A_i butithweight choice leave right balance heavy Find order put weight balance rule stre S satisfy
1graph
monocarp playing computer game now want complete level gameA level rectangular grid 2 row n column Monocarp control character start cell 1 1 intersection 1st row 1st columnmonocarp character cell step cell adjacent andor corner formally possible cell x_1 y_1 cell x_2 y_2 step x_1 x_2 le 1 y_1 y_2 le 1 obviously prohibit outside gridThere trap cell if Monocarps character find cell die game endsTo complete level Monocarps character reach cell 2 n intersection row 2 column nHelp Monocarp determine possible complete level
1graph
it easy version problem the difference version node choose colorsTheofanis starving wants eat favorite food sheftalia however finish homework can help problemyou perfect binary tree 2k 1 node binary tree vertex 1 2k 1 1 exactly child vertex 2i 2i 1 vertex 2k 1 2k 1 do not child you want color vertex 6 Rubiks cube color White Green Red Blue Orange YellowLets color good edge connect node color neighboring side Rubiks cube a picture Rubiks cube 2D map more formally white node neighboring white yellow node yellow node neighboring white yellow node green node neighboring green blue node blue node neighboring green blue node red node neighboring red orange node orange node neighboring red orange node you want calculate number good coloring binary tree two coloring consider different node color different colorthe answer large output answer modulo 1097
2string
Theofanis string s_1 s_2 dots s_n character c he want character stre equal c minimum number operationsin operation choose number x 1 le x le n position divisible x replace s_i c find minimum number operation require character equal c xs use operation
2string
this problem complicate version d1 significant difference read statementpolycarp array n n integer a_1 a_2 dot a_n Polycarp conceive positive integer k after Polycarp begin perform follow operation array index 1 le le n reduce number a_i kAfter Polycarp perform possibly zero number operation turn half number array find maximum k situation possible print 1 number arbitrarily large
1graph
one day Ahmed_Hossam go Hemose say Lets solve gym contest Hemose do not want play Valorant come problem tell Ahmed distract sadly Ahmed can not solve could help himThere Agent Valorant n weapon the ith weapon damage value a_i agent face enemy health value HThe Agent perform move enemy diesIn choose weapon decrease enemys health damage value the enemy die health equal 0 however easy agent can not choose weapon 2 time rowwhat minimum number time Agent need use weapon kill enemy
1graph
petya root tree integer write vertex the vertex 1 root you answer question treea tree connect graph cycle a rooted tree special vertex call root the parent node v vertex short path v rooteach question define integer v l k to answer question need perform follow step first write sequence integer write short path vertex v root include write v root Count number time integer occur Remove integer l occurrence replace sequence remove duplicate order element number occurrence original list increase order in case tie choose order element arbitrary the answer question kth number remain sequence Note answer uniquely determine ordering also possible length sequence step k case answer 1 for example sequence integer path v root 2 2 1 7 1 1 4 4 4 4 l 2 k 2 answer 1please answer question tree
1graph
petya array integer a_1 a_2 ldot a_n he like sorted array unfortunately give array arbitrary Petya want sort itPetya like challenge want sort array 3cycles more formally operation pick 3 pairwise distinct index j k 1 leq j k leq n apply j k cycle array it simultaneously place a_i position j a_j position k a_k position change elementfor example 10 50 20 30 40 60 choose 2 j 1 k 5 array underline50 underline40 20 30 underline10 60petya apply arbitrary number 3cycles possibly zero you determine Petya sort array ie nondecrease
1graph
she utmost flawlessly carry person rite preserve world balance yin yangHu Tao little prankster try scare graph problem you give connect undirected graph n node m edge you q query each query consist node bInitially edge graph weight 0 for query choose simple path start end b then add 1 edge path determine possible processing q query edge graph weight if output choice path query if possible determine small number extra query add possible it show number exceed 1018 give constraintsA simple path define path visit node onceAn edge say weight value divisible 2
1graph
Luntik decide try singe he oneminute song b twominute song c threeminute song he wants distribute song concert song include exactly concerthe want absolute difference duration concert small possible the duration concert sum duration song concertplease help Luntik find minimal possible difference minute concert duration
0array
let c_1 c_2 ldot c_n permutation integer 1 2 ldot n consider subsegment permutation contain integer x give integer m integer x good exactly m different value maximum subsegmentsCirno study mathematic teacher ask count number permutation length n exactly k good numbersunfortunately Cirno is not good mathematic can not answer question therefore ask helpsince answer big need tell number permutation modulo pa permutation array consist n distinct integer 1 n arbitrary order for example 23154 permutation 122 permutation 2 appear twice array 134 permutation n3 4 arrayA sequence subsegment sequence b obtain b deletion possibly zero element begin possibly zero element end
2string
an important meeting hold exactly n people invite at moment people step talk private the people talk want time meetingEach person limit sociability the sociability ith person nonnegative integer a_i this mean exactly a_i talk person leave meet talk anymore if a_i 0 ith person leave meet immediately startsA meeting consider productive maximum possible number talk take place ityou give array sociability determine people talk total number talk large possible
1graph
Casimir string s consist capital latin letter a b c each turn choose follow action erase exactly letter a exactly letter b arbitrary place string letter do not adjacent erase exactly letter B exactly letter C arbitrary place string letter do not adjacent therefore turn length string decrease exactly 2 all turn independent turn Casimir choose possible actionsfor example sabcabc obtain string sacbc turn erase occurrence b second occurrence A there option turn aside particular examplefor give string s determine sequence action lead string in word Casimirs goal erase letter string Is way
1graph
the Kingdom Islands consist p island as king rule kingdom island rule jarl rule in total n jarl jurisdictionEach island kingdom strong tradition jarl rule island support conflict the downside strength cultural conflict people inhabit different island Thus jarl rule different island conflicthowever recent year bring change traditional relation jarl to knowledge exactly k pair jarls relationship jarl pair different traditional that jarl pair know rule island jarl conflict if rule different island overcome cultural disagreement conflict anymoreas true responsible king worry kingdom close major conflict in order estimate current situation like find large possible group jarls jarls group conflict
2string
the Just Kingdom rule king n lord number 1 n each lord vassal overlord king different lord close king the king lord kindEach lord certain need express certain money need however lord king receive money split equally vassal unmet need only need vassal meet money fulfill need if money leave return excess overlord follow standard procedure distribute moneyat beginning year king receive certain sum tax money proceed split according rule if tax money great total need lord procedure guarantee everybodys need fulfil excess money leave king however money lord need metFor lord determine minimum tax money king receive lord need meet
1graph
life discover Venus what life form appear convex polygon an international consortium designing probe send Venus picture need estimate bandwidth need send pictureswhen probe take picture life form wish send Earth bandwidth require proportional area bounding box word smallest axisaligned rectangle contain lifeform the shape size life form know orientation relative camera random you determine expect average area bounding box orientation
1graph
let consider game Sticky Tetris in game field n time m square Tiles appear field player tile each tile 4connected set 7 squareseach new tile appear position fit inside field intersect tile cell tile row field the player tile leave right moment tile entirely fit inside field intersect tile the player stop tile position time after move since Sticky Tetris tile fall stoppedyou give final configuration Sticky Tetris game you need restore sequence step lead configuration exist
2string
Mr Chaneks city represent plane he want build housing complex citythere telephone pole plane represent grid size n 1 time m 1 there telephone pole x y a_x y 1for point x y define Sx y square Euclidean distance near pole x y Formally square euclidean distance point x_1 y_1 x_2 y_2 x_2 x_12 y_2 y_12To optimize building plan project supervisor ask sum Sx y 0 leq x leq n 0 leq y leq m help find value sum_x0n sum_y0 m Sx y
1graph
Chanek Jones help longlost relative Indiana Jones find secret treasure maze bury desert illusionsthe map labyrinth form tree n room number 1 n n 1 tunnel connect possible travel pair room tunnelsthe ith room 1 leq leq n a_i illusion rate to xth room yth room exist tunnel x y take maxa_x a_y a_x a_y energy z denote absolute value zto prevent grave robber maze change illusion rate room Chanek Indiana ask q queriesthere type query 1 u c the illusion rate xth room change c 1 leq u leq n 0 leq c leq 109 2 u v Chanek Indiana ask minimum sum energy need secret treasure room v initially room u 1 leq u v leq n help portion treasure
2string
Mr chanek array n integer the prettiness value denote assum_i1n sum_j1n gcda_i a_j cdot gcdi jwhere gcdx y denote great common divisor GCD integers x yin word prettiness value array total sum gcda_i a_j cdot gcdi j pair jhelp Mr Chanek find prettiness value output result modulo 109 7
1graph
there city park represent tree n attraction vertex n 1 rail edge the ith attraction happiness value a_ieach rail color it black t_i 0 white t_i 1 black train operate black rail track white train operate white rail track if previously black train want ride white train previously white train want ride black train need use 1 ticketthe path tour simple path visit attraction you need ticket time board train you k ticket mean switch train type k time in particular need ticket path consist rail colordefine fu v sum happiness value attraction tour u v simple path start uth attraction end vth attraction find sum fuv valid tour u v 1 leq u leq v leq n need k ticket modulo 109 7
1graph
Ivan play roguelike computer game he control single hero game the hero n equipment slot there list c_i item ith slot jth increase hero strength a_ij the item slot pairwise distinct list increase order strength increase so a_i1 a_i2 dot a_ic_iFor slot Ivan choose exactly item let choose item ith slot b_ith item corresponding list the sequence choice b_1 b_2 dots b_n call buildThe strength build sum strength increase item some build ban game there list m pairwise distinct ban build its guarantee there s build that s bannedwhat build maximum strength ban game if multiple build maximum strength print
1graph
a bracket sequence string contain character a regular bracket sequence bracket sequence transform correct arithmetic expression insert character 1 original character sequence for example bracket sequence regular result expression 11 111 notyou give integer n your goal construct print exactly n different regular bracket sequence length 2n
2string
you give digital clock n digit each digit show integer 0 9 clock show integer 0 10n1 the clock lead zeroes number small 10n1You want clock 0 operation possible in operation follow decrease number clock 1 swap digit choose digit swap do not adjacent your task determine minimum number operation need clock 0
2string
you give book n chapterseach chapter specify list chapter need understand order understand chapter to understand chapter read understand chapter require listcurrently do not understand chapter you going read book begin till end repeatedly understand book Note read chapter moment do not understand require chapter do not understand chapterDetermine time read book understand chapter determine understand chapter matter time read book
1graph
you give simple undirected graph n vertex n you go write letter vertex each letter k letter Latin alphabeta path graph call hamiltonian visit vertex exactly a string call palindromic read leave right right leave a path graph call palindromic letter vertex spell palindromic string change ordera string length n good letter k lowercase Latin letter write ith letter string ith vertex graph exist palindromic hamiltonian path graph Note path do not necesserily vertice order 1 2 dot ncount number good string
1graph