ProblemDescriptionYouaregivenatreewithNnodeswhicharenumberedbyintegers1..N.Eachnodeisassociatedwithanintegerastheweight.YourtaskistodealwithMoperationsof4types:1.Deleteanedge(x,y)fromthetree,andthenaddanewedge(a,b).Weensurethatitstillconstitutesatreeafteraddingthenewedge.2.Giventwonodesaandbinthetree,changetheweightsofallthenodesonthepathconnectingnodeaandb(includingnodeaandb)toaparticu...
ProblemDescriptionThecounter-terroristsfoundatimebombinthedust.Butthistimetheterroristsimproveonthetimebomb.Thenumbersequenceofthetimebombcountsfrom1toN.Ifthecurrentnumbersequenceincludesthesub-sequence"49",thepoweroftheblastwouldaddonepoint.Nowthecounter-terroristknowsthenumberN.Theywanttoknowthefinalpointsofthepower.Canyouhelpthem? InputThefirstlineofinputconsistsofanintegerT(...
ProblemDescriptionWehavemetsomanyproblemsonthetree,sotodaywewillhaveaqueryproblemonasetoftrees.ThereareNnodes,eachnodewillhaveauniqueweightWi.Wewillhavefourkindsofoperationsonitandyoushouldsolvethemefficiently.Wishyouhavefun! InputTherearemultipletestcasesinourdataset.Foreachcase,thefirstlinecontainsonlyoneintegerN.(1≤N≤300000)ThenextN‐1lineseachcontainstwointegersx,ywhichme...
ProblemDescriptionXORisakindofbitoperator,wedefinethatasfollow:fortwobinarybasenumberAandB,letC=AXORB,thenforeachbitofC,wecangetitsvaluebycheckthedigitofcorrespondingpositioninAandB.Andforeachdigit,1XOR1=0,1XOR0=1,0XOR1=1,0XOR0=0.Andwesimplywritethisoperatoras^,like3^1=2,4^3=7.XORisanamazingoperatorandthisisaquestionaboutXOR.WecanchooseseveralnumbersanddoXOR...
近期评论