"Team Game #" Usaco 2006 January Bronze

Source: Internet
Author: User

"A question" A. Stump Removal Link Click here~~

" The main idea" a row of rough stumps, need to bomb all blown up, if a stump of the front and back of the stump height is smaller than it, the bomb will explode at the same time, for as little as possible to place the number of bombs, the number of the output stump.

"problem-solving ideas" understand test instructions, from left to right sweep, if the current position to the right or left than it is lower or equal, then the position blew up, and then the explosion can be blown, judging the current stump front and behind the height of comparison,

Core code

for (int i=1;i<=n+1;i++)    {        if (a[i]>=a[i-1]&&a[i]>=a[i+1])        Cout<<i<<endl ;    }
"Question F"F. Dollar Dayz BNU 14323

" big number!" Solve the problem of coin combination, pit problem together ~ ~

Code:

/*AUTHOR:HRW Large number! */#include <string> #include <stdio.h> #include <algorithm> #include <iostream> #include <    bits/stdc++.h>using namespace Std;const int maxn = 1001;struct bign{int LEN,S[MAXN];        Bign () {memset (s,0,sizeof (s));    len = 1;        } bign operator = (const char *num) {len = strlen (num);        for (int i=0; i<len; i++) s[i] = num[len-i-1]-' 0 ';    return *this;        } bign operator = (int num) {char S[MAXN];        sprintf (S, "%d", num);        *this = s;    return *this;    } bign (int num) {*this = num;    } bign (const char *num) {*this = num;        } string str () const {String res = "";        for (int i=0; i<len; i++) res = (char) (s[i] + ' 0 ') + res;        if (res = = "") res = "0";    return res;        } bign operator + (const bign& b) const {bign C;        C.len = 0;        for (int i=0,g = 0; g| | I<max (Len,b.len); i++){int x = g;            if (I<len) x+= s[i];            if (I<b.len) x+=b.s[i];            c.s[c.len++] = x%10;        g = X/10;    } return C;    } void Clean () {while (len > 1 &&!s[len-1]) len--;        } bign operator + = (Const bign& b) {*this = *this + b;    return *this;    }};istream& operator >> (IStream &in, bign& x) {string S;    in>>s;    x = S.c_str (); return in;}    ostream& operator << (ostream &out, const bign& x) {out << x.str (); return out;}    Bign Ac[1002];int Main () {int n,k;        while (cin>>n>>k) {ac[0] = 1;            for (int i=1, i<=k; i++) for (int j=i; j<=n; j + +) Ac[j]+=ac[j-i];    cout<<ac[n]<<endl; } return 0;}
"E question"E. Redundant Paths BNU14319

" to the main idea" to give you a connected undirected graph G, at least to add a few edges, in order to make it into a double-connected graph, and POJ 31,771-like

"The idea of solving problems" a connected diagram with a bridge to become a double-connected graph, the double connected graph is shrunk to a point, forming a tree, need to add the edge for (l+1)/2,l as the number of leaf nodes

PS:BNU unexpectedly add plug will time out ~~orz, later still have to pay more attention.

Code:

/**/#include <bits/stdc++.h>using namespace Std;const int maxn=5010;//points const int maxm=20100;//Edge number, non-struct edge{    int to,next; BOOL cut;//is the bridge tag} edge[maxm];int head[maxn],tot;int Low[maxn],dfn[maxn],stack[maxn],belong[maxn];int Index,top;int    The number of block;//side double connected blocks bool Instack[maxn];int bridge;//Bridge of void Addedge (int u,int v) {edge[tot].to=v;    Edge[tot].next=head[u];    Edge[tot].cut=false; head[u]=tot++;}    void Tarjan (int u,int pre) {int V;    Low[u]=dfn[u]=++index;    Stack[top++]=u;    Instack[u]=true;        for (int i=head[u];i!=-1;i=edge[i].next) {v=edge[i].to;        if (v = = pre) continue; if (!            Dfn[v]) {Tarjan (v,u);            if (Low[u]>low[v]) low[u]=low[v];                if (Low[v]>dfn[u]) {bridge + +;                Edge[i].cut = true;            Edge[i^1].cut = true;    }} else if (Instack[v]&&low[u]>dfn[v]) low[u]=dfn[v];      } if (Low[u]==dfn[u]) {  block++;            do {v=stack[--top];            Instack[v]=false;        Belong[v]=block;    } while (V!=u);    }}void init () {tot=0; memset (head,-1,sizeof (Head));}    int du[maxn];//to form a tree, the degree of each point is void solve (int n) {memset (dfn,0,sizeof (DFN));    memset (instack,false,sizeof (instack));    index=top=block=0;    Tarjan (1,0);    int res=0;    memset (du,0,sizeof (du));    for (int i=1, i<=n; i++) for (int j=head[i]; j!=-1; j=edge[j].next) if (edge[j].cut) du[belong[i]]++; for (int i=1; i<=block; i++) if (du[i]==1) res++;//the number of leaf nodes to find is res, the structure edge dual connected graph needs to add edge (res+1)/2 printf ("%d\n", (res+1)/2);}    int Shuru () {int sum=0;    Char ch; while ((Ch=getchar ()) <= ' 0 ' | |    ch>= ' 9 '); sum=ch-' 0 ';    while ((Ch=getchar ()) >= ' 0 ' &&ch<= ' 9 ') sum=sum*10+ch-' 0 '; return sum;}    int main () {//freopen ("1.txt", "R", stdin);    int n,m,u,v;        while (scanf ("%d%d", &n,&m) ==2) {init ();        while (m--) {    scanf ("%d%d", &u,&v);            U=shuru ();            V=shuru ();            Addedge (U,V);        Addedge (V,u);    } solve (n); } return 0;}



"Team Game #" Usaco 2006 January Bronze

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.