csu and dsu

Want to know csu and dsu? we have a huge selection of csu and dsu information on alibabacloud.com

CSU 1769 (mathematics)

Owners" of 2 lives, and a "whirlwind effect" followed by 2 life-threatening "slave-owners" and 1 1-point life "terror slaves".In this series of topic 2 we have learned how to calculate how many "horrible slave owners" will be left after the N-whirlwind effect. Now that the game has a bug, the number of slave owners on the field is no longer limited by the 7 limit. There are some 1 lives left on the field, some 2 lives, some 3 life slaves, and now ask the slave owners to go through the N-whirlwi

CSU OJ 1811:tree intersection (heuristic merge)

) { theEdge[tot].next =Head[u]; *Edge[tot].to =v; $Edge[tot].index =ID;Panax NotoginsengHead[u] = tot++; - } the + voidDfsintUintPreintID) { ACnt[u][color[u]] =1; theAns[u] = Cnt[u][color[u]] 1:0; + for(inti = Head[u]; ~i; i =Edge[i].next) { - intv =edge[i].to; $ if(v = =pre) $ Continue; - Dfs (V, u, edge[i].index); - if(Cnt[u].size () cnt[v].size ()) { the swap (Cnt[u], cnt[v]); - swap (Ans[u], ans[v]);Wuyi } the for(Auto It:cnt[v]) { -

CSU 1120 virus (Classic template example: Maximum public increment subsequence)

output.Sample Input19 1 4 2 6 3 8 5 9 16 2 7 6 3 5 1Sample Output3 compared to the monotonically increasing, the longest common subsequence, this problem will combine the two, very classic example. 1#include 2#include 3#include string.h>4#include 5 using namespacestd;6 Const intmaxn=1005;7 intdp[maxn],a[maxn],b[maxn],n,m;8 intLICs ()9 {Ten intI,j,max; OneMemset (DP,0,sizeof(DP)); A for(i=1; i) - { -max=0; the for(j=1; j) - { - if(A[i]>b[j] maxDp[j]) -M

Math---CSU 1554:sg Value

--) {LL type; CIN>>type; if(type==1)//Insert{LL num; CIN>>num; if(num>v+1) {q.push (num); } Else{v+=num; while(!Q.empty ()) {LL tmp=Q.top (); if(tmp1) {v+=tmp; Q.pop (); } Else Break; } } } Elsecout1Endl; } } return 0; } /* */ /*******************************************

CSU 1548:design Road (three points)

Test instructions: Needs to be repaired from (0,0) point to (x, y)Where there are n and y axes parallel to the riverUnit cost of road repairing C1 repair Bridge Unit Cost C2Q What is the minimum total cost?Idea: Merge all the riversThe length of the bridge repeatedlyFind the minimum cost#include   CSU 1548:design Road (three points)

Water---CSU 1550:simple String

) {if(dd[i]>0) {sum+=Dd[i]; if(dd[i]>Bb[i]) {Flag=false; Break; } } } if(!flag) {Puts ("NO"); Continue; } inthalf=len/2; Sum=0; for(intI=0;i -;++i) {if(dd[i]0) {sum+=min (bb[i],cc[i]); } Else{sum+=min (bb[i],cc[i]); } } if(sum>=half) {Puts ("YES"); Continue; } Else{puts ("NO"); Continue; } } return 0;}/**//****************************************

Three-point---CSU 1548:design Road

) { DoubleL=low,h=High ; DoubleMid= (L+H)/2, mmid= (mid+h)/2; DoubleCmid=calc (mid), cmmid=Calc (mmid); while(Fabs (Cmmid-cmid) >=1e-Ten) { if(cmid>cmmid) L=mid; Elseh=Mmid; Mid= (l+h)/2, mmid= (mid+h)/2; Cmid=calc (mid), cmmid=Calc (mmid); } returnmin (cmmid,cmid);}intMain () {intN; while(cin>>n>>x>>y>>c1>>C2) {Sum=0.0; DoubleTMP1,TMP2; for(intI=1; ii) {cin>>tmp1>>TMP2; Sum+=TMP2; } xx=x-sum; printf ("%.2lf\n", Solve (0.0, y)); } return 0;}View Cod

CSU 1526 Beam Me out! Strong connectivity

Topic Link: Click to open the linkTest instructionsA direction graph for a given n points (1 is the starting point and N is the end point)Each of the following lines gives the degree of a point and the next point to which it is connected.The nth point is not out of the degreeThe picture is like this: 1->2, 1->3, 2->3First question:If there is a scheme that allows this person to enter a point and no longer reach the end of the output PRISON, otherwise the output pardonSecond question:If this pers

CSU 1552:friends graph theory match + super large prime number judgment

//Dfs Augmentation Road the {Bayi for(intI=1; i) the { the if(edge[x][i]!Vis[i]) - { -vis[i]=1; the if(lin[i]==-1|| DFS (Lin[i]))//I have no matching or matching can get the augmented path the { thelin[i]=x; the return true; - } the } the } the return false;94 } the the intMain () the {98 while(SCANF ("%d", n)! =EOF) About { -Memset (Edge,0,size

CSU 1395:timebomb (Analog)

Test instructions: Give some numbers if they can be divisible by 6 output beer!! Otherwise output boom!!Idea: Save 0 to 9 with a three-dimensional arrayViolence out of every number of valuesFind the results(This is a bit of a hole in the 1 number may not exist 2 number of uncertainties)#include   CSU 1395:timebomb (Analog)

CSU 1757 (greedy or tree-like array)

.#include #include#include#include#includeusing namespacestd;Const intN =100005;intX[n],a[n],b[n];intC[n],n;intLowbit (inti) { returni (-i);}voidUpdateintIdxintv) { for(inti=idx;i2*n;i+=lowbit (i)) {C[i]+=v; }}intGetsum (intidx) { intsum =0; for(inti=idx;i>=1; i-=lowbit (i)) {Sum+=C[i]; } returnsum;}intMain () {inttcase; scanf ("%d",tcase); while(tcase--) {memset (c,0,sizeof(c)); scanf ("%d",N); intCNT =1; for(intI=1; i) {scanf ("%d%d",a[i],B[i]); X[cnt++] =A[i]; X[cnt++] =B[i];

CSU 1515 Sequence (Mo team algorithm)

; I i) {if(A[i].val = = a[i-1].val) B[i] = b[i-1]; Else if(A[i].val = = a[i-1].val +1) B[i] = b[i-1]+1; ElseB[i] = b[i-1] +2; } for(inti =1; I i) {c[A[i].pos]=B[i];} memset (tmp,0,sizeoftmp); for(inti =0; I i) {scanf ("%d%d", q[i].l,Q[I].R); Q[i].id=i; } sort (q, q+m); intPL =1, PR =0; ll ans=0; for(inti =0; I i) {intID =q[i].id; intL =Q[I].L; intR =Q[I].R; if(PR for(inti = pr+1; I 1); Else for(inti = PR; i > R; -i) ans + = Update (C[i],-1); if(PL for(inti = pl; I 1); PR= r,

"Scan line or tree-like array" CSU 1335 Takahashi and Low bridge

); + } - returnRes; the } * voidInit () $ {Panax Notoginsengmemset (Tree,0,sizeof(tree)); - } the intMain () + { A intcas=0; the while(~SCANF ("%d%d%d",n,m,k)) + { - init (); $ for(intI=1; i) $ { -scanf"%d",a[i]); - } theSort (A +1, a+n+1); - intx, y;Wuyi intst=1, ed; the for(intI=1; i) - { Wuscanf"%d%d",x,y); -Ed=x; About intPos1=upper_bound (A +1, A +1+N,ST)-A; $ intPos2=upper_bound (A +1, A

CSU-1632 repeated substrings[suffix array to find the number of substrings that occur repeatedly]

Evaluation Address: https://cn.vjudge.net/problem/CSU-1632Descriptionin the string, all occurrences of at least 2 number of sub-strings of the secondInputfirst act an integer T (t represents the number of use case groups, with each group of use cases occupying a length of 100000 the stringOutputFor each set of use cases, output the number of substrings that appear at least two times in the stringSample Input3AabaabAaaaaAaAaASample Output545SolutionAns

CSU 1337 (flt theorem)

CSU 1337Time Limit:1000MSMemory Limit:131072KB64bit IO Format:%LLD %lluDescriptionFlt theorem: When n>2, the indefinite equation AN+BN=CN has no positive integer solution. For example, A3+B3=C3 does not have a positive integer solution. To enliven the atmosphere, we might as well have a funny version: Change the equation to a3+b3=c3, so there are solutions, such as a=4, B=9, c=79 43+93=793.Enter two integers x, y, to satisfy the xInputEnter up to 10 s

CSU 1312 CX and girls (Shortest Path)

1321: Cx and girlstime limit: 1 sec memory limit: 128 MB Submit: 432 solved: 124 [Submit] [Status] [web board] Description CX is to rush to class. In order not to be late, it is necessary to arrive at the classroom in the shortest path. At the same time, CX hopes to see more students on the way, the better. Now, the map is abstracted into an undirected graph. CX starts from, and the classroom is at, telling the number of school girls at each point and the length of each edge. Find the maximum

CSU 1355 Landmine clearance plan grid map clean up minimal mines make diagonal

integers n, m, K (1 n, mK N rows, each with M characters, describing the game map. Which '. ' Represents a cell without a mine, ' * ' indicates a cell with a mine (if the mine is cleared, the lattice becomes a mine-free cell). Data ensure that the total number of mines does not exceed 200, (1, 1) and (N, M) The Manhattan distance of any one mine is greater than K.OutputFor each set of test data, one line is used to output an integer that indicates at least how many gold coins are needed to clea

CSU 1160 (hexadecimal problem), csu1160 hexadecimal Problem

CSU 1160 (hexadecimal problem), csu1160 hexadecimal ProblemCSU 1160Time Limit:1000 MSMemory Limit:131072KB64bit IO Format:% Lld % llu Description Converts a decimal integer to a hexadecimal value. The format starts with 0x and ranges from 10 to 10 ~ 15 uppercase letters ~ F. Input Each row has an integer x, 0 Output The eight-digit hexadecimal integer corresponding to the output of each row, including the leading 0. Sample Input 01023 Sample Output

CSU 1529 Equator DP

CSU 1529 Equator DP Queue optimization DP Equator Time Limit:5000 MS Memory Limit:131072KB 64bit IO Format:% Lld % llu Submit Status Description Input Output Sample Input 3 3 1 2 3 8 4 5 -1 -1 1 -1 -1 5 2 -1 -1 Sample Output 6 14 0 /*************************************** * ******** Author: CKbossCreated Time: Tuesday, March 17, 2015 File Name: CSU1529.cpp *************************************** * *********/

CSU 1633:landline Telephone Network (minimum spanning tree)

through any insecure building C in the Network (where C is different from A and B).Inputthe input consists of a single test case. The first line contains three integers n, m, p where 1≤n≤1000 are the number of buildings, 0≤m≤100000 is the number of possible direct connections between a pair of buildings, and 0≤p≤n is the number of insecure buildings. The buildings is numbered from 1 to N. The second line contains p distinct integers between 1 and n (inclusive), which is the numbers of insecure

Total Pages: 15 1 .... 3 4 5 6 7 .... 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.