??xml version="1.0" encoding="utf-8" standalone="yes"?>久久国产色AV免费看,无码人妻久久久一区二区三区,91精品国产色综久久http://m.shnenglu.com/zqsand/category/12847.html啥是子标?/description>zh-cnWed, 20 Jan 2010 11:25:10 GMTWed, 20 Jan 2010 11:25:10 GMT60TC-Practice-Recordhttp://m.shnenglu.com/zqsand/archive/2009/12/26/104143.htmlrikisandrikisandSat, 26 Dec 2009 09:28:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/12/26/104143.htmlhttp://m.shnenglu.com/zqsand/comments/104143.htmlhttp://m.shnenglu.com/zqsand/archive/2009/12/26/104143.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/104143.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/104143.htmltchs-1 none 1000pt DFS 利用q入的方向划分四个边

tchs-2 250pt 直接就?我写??500pt 暴力可以q,但是判断时候不能用stringstream 用算术判?也可以用构造法 1000pt 每一位有三种可能?/p>

           不用Q保持不动,变化Q分别递归计算valueq更新结果即可,׃递归深度最多只?3层所以不会tle

           另外也可以写出基Cؓ3的@环来遍历每一U情况具体看代码

    for(i=0,A[0]++;A[i]>2;i++){
       A[i]=0;A[i+1]++;
  }

tchs-3 1000pt 要想使乘U最大,需要更多的3卛_ 500pt 又看错题?~~~ft 要注意题目一定要看清?/p>

tchs-4 500pt 模拟题,好难?音乐的~ 可以都乘?6 用整数来计算 点会很烦~ q种题思\要清?一步一步来



rikisand 2009-12-26 17:28 发表评论
]]>
TOPCODER-SRM455http://m.shnenglu.com/zqsand/archive/2009/12/19/103524.htmlrikisandrikisandSat, 19 Dec 2009 06:07:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/12/19/103524.htmlhttp://m.shnenglu.com/zqsand/comments/103524.htmlhttp://m.shnenglu.com/zqsand/archive/2009/12/19/103524.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/103524.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/103524.html阅读全文

rikisand 2009-12-19 14:07 发表评论
]]>
TC-SRM-454_div2http://m.shnenglu.com/zqsand/archive/2009/12/13/103088.htmlrikisandrikisandSun, 13 Dec 2009 02:18:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/12/13/103088.htmlhttp://m.shnenglu.com/zqsand/comments/103088.htmlhttp://m.shnenglu.com/zqsand/archive/2009/12/13/103088.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/103088.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/103088.html阅读全文

rikisand 2009-12-13 10:18 发表评论
]]>
Topcoer SRM 453.5http://m.shnenglu.com/zqsand/archive/2009/12/11/103001.htmlrikisandrikisandFri, 11 Dec 2009 11:59:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/12/11/103001.htmlhttp://m.shnenglu.com/zqsand/comments/103001.htmlhttp://m.shnenglu.com/zqsand/archive/2009/12/11/103001.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/103001.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/103001.html阅读全文

rikisand 2009-12-11 19:59 发表评论
]]>
TC-SRM-233-1000pt BFShttp://m.shnenglu.com/zqsand/archive/2009/11/25/101897.htmlrikisandrikisandWed, 25 Nov 2009 03:39:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/11/25/101897.htmlhttp://m.shnenglu.com/zqsand/comments/101897.htmlhttp://m.shnenglu.com/zqsand/archive/2009/11/25/101897.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/101897.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/101897.htmll箋是misof 数字教学里面的习题~ W一的最后一道题了~
Problem Statement

You are in a maze containing revolving doors. The doors can be turned 90 degrees by pushing against them in either direction. You are to find a route from the start square to the end square that involves revolving as few doors as possible. Given a map of the maze, determine the fewest number of door revolutions necessary to get from the start to the end.

In the map:

   ' ': empty space
   '#': wall
   'O': center of a revolving door (letter "oh", not zero)
   '-': horizontal door (always adjacent to a 'O')
   '|': vertical door (always adjacent to a 'O')
   'S': start square
   'E': end square

Each revolving door will always be oriented horizontally (with two horizontal segments) or vertically (with two vertical segments):

    |
    O  or  -O-
    |

Doors can be revolved 90 degrees by moving onto a door segment from any of the 4 squares diagonally adjacent to the door center, i.e., the 'X' characters below:

   X|X     X X
    O  or  -O-
   X|X     X X

Here is an example map:

        ###
        #E#
       ## #
    ####  ##
    # S -O-#
    # ###  #
    #      #
    ########

In this example, 2 door revolutions are necessary to get from 'S' to 'E'. The first turn is shown here:

        ###         ###
        #E#         #E#
       ## #        ## #
    ####  ##    #### |##
    # S -O-#    # S  OX#
    # ### X#    # ###| #
    #      #    #      #
    ########    ########

And the second turn is shown here:

        ###         ###
        #E#         #E#
       ## #        ## #
    ####X|##    #### X##
    # S  O #    # S -O-#
    # ###| #    # ###  #
    #      #    #      #
    ########    ########

Your method should return an int, the minimum number of door revolutions necessary to get from the start square to the end square. If there is no way to reach the end square, return -1.

Definition

Class:
RevolvingDoors

Method:
turns

Parameters:
vector <string>

Returns:
int

Method signature:
int turns(vector <string> map)

(be sure your method is public)

Notes

-
Assume that all squares off the edge of the map are walls.

Constraints

-
map will contain between 3 and 50 elements, inclusive.

-
Each element of map will contain between 3 and 50 characters, inclusive.

-
Each element of map will contain the same number of characters.

-
Each character in map will be one of 'S', 'E', 'O', '-', '|', '#', and ' ' (space).

-
There will be exactly one 'S' and one 'E' in map.

-
There will be between 1 and 10 doors, inclusive, and they will be formatted in map as described in the problem statement.

-
No two doors will be close enough for any part of them to occupy the same square.

-
It is not allowed for a door to be blocked and unable to turn. There will not be any walls in any of the 4 squares immediately adjacent to the center of a door, nor will a door be on the edge of the map.

关键是门的状态表C,参考了|站上的代码Q挑了一个比较简l的Q用的优先队列。写完调好发现TLE 囧~ copy出网站上的再run依然TLE``` ``` 看了下发现现在的system testing 比原来增加了几个试用例~~~   于是扑ևmisof大牛的解法,发现对状态处理一L(fng)~~~只不q用了memo和dequeQ省M优先U队列调整的旉开销Q改好了pass了~ 上代码~~Q?/strong>
Code Snippet
using namespace std;
typedef long long int64;  
typedef vector<int> VI;
typedef vector<string> VS;
#define inf 1000000
#define REP(i,n) for(int (i)=(0);((i)<(n));++(i))
template<class T> inline void checkmin(T &a,const T &b) { if (b<a) a=b; }
template<class T> inline void checkmax(T &a,const T &b) { if (b>a) a=b; }
int dr[]={-1,0,1,0};
int dc[]={0,1,0,-1};
struct state{state(int x,int y,int z,int s):r(x),c(y),doorstate(z),best(s){}int r;int c;int doorstate;int best;};
int memo[56][56][1<<11];
class RevolvingDoors
{
        public:
        int turns(vector <string> mp)
        {
             int x=mp.size()+2;int y=mp[0].size()+2;
             int sr,sc,er,ec,cnt=0,doorInit=0;
             REP(i,x-2)mp[i]='#'+mp[i]+'#';                //trick:modify the pattern to make it easy to loop
             mp.insert(mp.begin(),string(58,'#'));
             mp.push_back(string(58,'#'));
             REP(i,x)REP(j,y)if(mp[i][j]=='S'){mp[i][j]=' ';sr=i;sc=j;}else if(mp[i][j]=='E'){mp[i][j]=' ';er=i;ec=j;}
             REP(i,x)REP(j,y)if(mp[i][j]=='O'){if(mp[i-1][j]=='|')doorInit|=(1<<cnt);
                mp[i-1][j]=mp[i+1][j] = 100 + cnt*2 +1;    //use the content in the box to identify the door number,and the door pos
                mp[i][j-1]=mp[i][j+1] = 100 + cnt*2 ;    //if pos==0 it means this box is on the left or right of the door
                cnt++; mp[i][j]='#';
             }
             REP(i,x)REP(j,y)REP(t,1<<cnt) memo[i][j][t] = inf;    //init the memo
             deque<state> Q; Q.push_back(state(sr,sc,doorInit,0));
             while(!Q.empty()){
                state now=Q.front();Q.pop_front();
                int r=now.r  , c=now.c  , door=now.doorstate , b=now.best;
                if( memo[r][c][door] < b)continue;    //no better ,no vist
                REP(dir,4){                            //try four direction
                    int nr=r+dr[dir],nc=c+dc[dir];
                    if(mp[nr][nc]==' '){
                        if(memo[nr][nc][door] > b){ memo[nr][nc][door]=b;Q.push_back(state(nr,nc,door,b));}
                    }
                    else if(mp[nr][nc]=='#')continue;
                    else{                            //if we come to a box near to the door-mid
                        int doornum=(mp[nr][nc]-100)/2;int open=(mp[nr][nc]-100)%2;    
                        if( ((door>>doornum)&1) != open){    //lucily,the box is empty
                            if(memo[nr][nc][door] > b){memo[nr][nc][door] = b;Q.push_back(state(nr,nc,door,b));}
                        }        
                        else {                                // the box has a door
                            if(open==0 && dr[dir]==0) continue;    //try to define the relative pos between the direction and the box
                            if(open==1 && dc[dir]==0) continue;    //also ~ if we cannot push the door we give up
                            int ndoor=door^(1<<doornum);    //we can go into the box if we push the door ~
                            if(memo[nr][nc][ndoor] > b+1 ){memo[nr][nc][ndoor] = b+1 ;Q.push_back(state(nr,nc,ndoor,b+1));}
                        }
                    }
                }
             }
             int ans=inf;
             REP(i,1<<cnt){ //loop to check the best ans~
                 if(memo[er][ec][i]<ans){ans=memo[er][ec][i];cout<<er<<" "<<ec<<" "<<hex<<i<<endl;}
             }
             if(ans == inf) return -1;
             else return ans;
        }

中文copy是ؕ?#183;··囧啊~~ 俺的破烂英文注释啊~~~



rikisand 2009-11-25 11:39 发表评论
]]>
TCCC-05-1000pt-http://m.shnenglu.com/zqsand/archive/2009/11/23/101697.htmlrikisandrikisandMon, 23 Nov 2009 07:29:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/11/23/101697.htmlhttp://m.shnenglu.com/zqsand/comments/101697.htmlhttp://m.shnenglu.com/zqsand/archive/2009/11/23/101697.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/101697.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/101697.htmlProblem Statement

Just before a chess match between two teams, each team's coach secretly determines an ordering of his team's players. The first players in each team then get to play against each other, the second players in each team play against each other, etc. The team with the most wins will win the match.

You are the coach for one of the teams, and you have somehow managed to find out the order of the players in the other team. Based on that, you want to order your players so that your team's expected score is maximized to your advantage. The expected score of a single game can be calculated by the following formula (which is directly derived from how the international chess rating system works):

EA = 1 / (1 + 10 (RB - RA)/400)

EB = 1 / (1 + 10 (RA - RB)/400)

where RA and RB are the ratings of player A and B, and EA and EB are the expected scores for each player. For instance, if RA is 2432 and RB is 2611, the expected score for player A is 1 / (1 + 10179/400) = 0.263005239459. The expected score for a team is the sum of the expected scores for the players in that team.

To make things a bit more complicated, the players in a team must be ordered such that a player with rating x plays before all players with rating strictly less than x - lim, where lim is a given non-negative integer. For example, if lim is 100, a player with rating 2437 must play before a player with rating 2336 but not necessarily before a player with rating 2337.

Create a class ChessMatch containing the method bestExpectedScore which takes a vector <int> teamA, the ratings of your players (in no particular order); a vector <int> teamB, the ratings of your opponent's players in the order they will play; and an int lim, the limit determining how freely you can order your players. You can assume that your opponent's players will be ordered in accordance with lim. The method should return a double, your team's expected score if you order your players optimally.

Definition

Class:
ChessMatch

Method:
bestExpectedScore

Parameters:
vector <int>, vector <int>, int

Returns:
double

Method signature:
double bestExpectedScore(vector <int> teamA, vector <int> teamB, int lim)

(be sure your method is public)

 

要求最好的得分Q要遍历所有的排列方式昄不可能。如果{化问题ؓ依次攄每个选手到每一个位|,那么只要求出剩下选手排列中得得分最大的可以了Q可以想到dpҎ(gu)的最有子问题定义?/font>

用每一位记录当前的选手分配情况Q如果ؓ0Q则已经分配Q如果ؓ1Q则q未分配。pos来记录当前要分配的位|。对于每一个子集,考虑每一个ؓ1的也是未分配的选手使位于pos位置Q然后check 是否满在他之后的球员(也就是剩下的?的位Q是否满x件的不等式,满则更新当前分配的最优成l。最l?2^N-1 的成l即为所求?/font>

Code Snippet
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define two(X) (1<<(X))
#define contain(S,X) ((S&two(X))>0)
#define eps 1e-9
double p[20][20];
int N;
double memo[1<<20];
int lim;VI A;
bool check(int now,int pos){
    REP(i,N)if(now&two(i)){
        if(A[pos]+lim<A[i])return false;
    }
    return true;
}
double solve(int now,int pos){
    if(now==0) return 0;
    if(memo[now]>-eps)return memo[now];
    REP(i,N) if(contain(now,i)&&check(now^two(i),i)){
         double tmp=p[i][pos]+solve(now^two(i),pos+1);
         if(tmp>memo[now]+eps) memo[now]=tmp;
    }
    return memo[now];
}

class ChessMatch
{
        public:
        double bestExpectedScore(vector <int> tA, vector <int> tB, int _lim)
        {
            N=tA.size(); lim=_lim;A=tA;
            REP(i,N)REP(j,N)  p[i][j]=1.0/(1.0+pow(10.0,double(tB[j]-tA[i])/400.0));
            REP(i,1<<N)memo[i]=-1;
            return solve(two(N)-1,0);  
        }

 

上面的方法用递归Q下面是使用递推的程序。即从子集出发最l到?^n-1的思\。在q里把A队伍先从大到排序。在每一个子集记录每一个未分配选手的得分和要分配的位置?/font>

E序中思\为:依次从子集中选取一个选手作ؓWbits-1个选手Q也是说子集中剩下的元素要攑֜q个选手前面Q由于选手从小到大遍历Q只需要遍历到s[j]<=s[bits-1]+lim 为止Q也p满q个子集中最的选手+lim >=选中?卛_Q然后更新当前子集的得分

注释中思\? 依次从子集选取一个选手作ؓ当前子集中的W一个元素,也就是整体的Wn-bits个元素,q次从大到小遍历Q这样只需要保证,位于子集W一个的元素+lim>=子集中最大的元素(s[0])Q即可,然后更新当前子集得分

最l全?^n-1的即为所?/font>

Code Snippet
class ChessMatch
{
        public:
        double bestExpectedScore(vector <int> ta, vector <int> tb, int _lim)
        {
                int n=ta.size();a=ta;lim=_lim;N=n;
                sort(ta.begin(),ta.end(),greater<int>());int s[32],pos[32];
                REP(i,n)REP(j,n)p[i][j]=1./(1.+pow(10.,double(tb[j]-ta[i])/400.));
                REP(mask,1<<n){
                    int bits=0;
                    dp[mask]=0.;
                    if(!mask)continue;
                    REP(i,n) if(contain(mask,i)){
                        s[bits]=ta[i];pos[bits++]=i;
                    }
                    //for (int j = 0 ; j < bits  && s[j] + lim >= s[0]; j++){
                    //    if(dp[mask] < p[pos[j]][n-bits]+dp[mask^two(pos[j])])
                    //        dp[mask]= p[pos[j]][n-bits]+dp[mask^two(pos[j])] ;
                    
                    for (int j = bits-1; j >= 0 && s[j] <= s[bits-1] + lim; j--){
                    if(    dp[mask] <  p[pos[j]][bits-1] + dp[mask & ~(1 << pos[j])] )
                      dp[mask] = p[pos[j]][bits-1] + dp[mask & ~(1 << pos[j])];
                    }
                }
                return dp[two(n)-1];
        }


rikisand 2009-11-23 15:29 发表评论
]]>
TC-05TCOR4-250 DPhttp://m.shnenglu.com/zqsand/archive/2009/11/22/101628.htmlrikisandrikisandSun, 22 Nov 2009 07:58:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/11/22/101628.htmlhttp://m.shnenglu.com/zqsand/comments/101628.htmlhttp://m.shnenglu.com/zqsand/archive/2009/11/22/101628.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/101628.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/101628.html
roblem Statement

Character j in element i (both 0-based) of messages denotes how many messages employee i sent to employee j. You will return a vector <int> containing the hierarchy of the employees within the company. Element 0 is the highest ranked employee, and so forth. The returned ranking should minimize the number of messages sent from lower ranked employees to higher ranked employees. If multiple solutions are possible, return the one with element 0 minimal. If there are still ties, minimize element 1, etc.

Definition

Class:
CompanyMessages

Method:
getRank

Parameters:
vector <string>

Returns:
vector <int>

Method signature:
vector <int> getRank(vector <string> messages)

(be sure your method is public)

Constraints

-
messages will contain between 2 and 15 elements inclusive.

-
Each element of messages will contain exactly N characters, where N is the number of elements in messages.

-
Each character in messages will be a digit ('0'-'9').

-
Character i in element i of messages will be '0'.

按照题目说明可知Q按照找到的序Q所有从低向高U发的信得数目和应该是最的。又观察刎ͼ只要定了第一个,也就是别最高的bossQ那么剩下的员工怎么排列Q他们向最高boss 发信数是不变的,从而子问题是在剩下员工中扑ֈ 低向高U发信数最的排列 Q显然这W合DP问题最优子l构的问题?/font>

T[1···N]=Min{sum(N <->{1-N-1},T[1-N-1] } 得到状态方E后很容易写出程?Q可以用备忘录dp

Code Snippet
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define two(X) (1<<(X))
#define contain(S,X) ((S&two(X))>0)

int A[1<<15];
vector<vector<int> > vec(1<<15);
class CompanyMessages
{
        public:
        vector <int> getRank(vector <string> mes )
        {
            int n=mes.size();
            REP(mask,two(n)){
                if(!mask)continue;
                A[mask]=100000;
                REP(i,n)if(contain(mask,i)){
                    int now=mask^two(i); int tmp=A[now];
                    REP(j,n)if(contain(now,j))tmp+=(mes[j][i]-'0');
                    if(tmp<A[mask]){
                        vec[mask].clear();vec[mask].push_back(i);
                        for(int s=0;s<vec[now].size();s++)vec[mask].push_back(vec[now][s]);
                        A[mask]=tmp;
                    }
                }
            }
            return vec[two(n)-1];
        }

 

Code Snippet
int memo[two(15)],record[two(15)];
VS M;int N;VI ans;
int solve(int now){
    if( now == 0 ) return 0;
    if( memo[now]>=0 )return memo[now];
    memo[now] = 100000;
    REP(i,N)if(contain(now,i)){
        int mask = now ^ two(i);int tmp = solve(mask);
        REP(j,N)if(contain(mask,j))tmp += (M[j][i] - '0');
        if(tmp < memo[now]) {
            memo[now]=tmp ;
            record[now] = mask;
        }
    }
    return memo[now];
}
void cacl(){
    int mask = two(N)-1;
    ans.clear();
    REP(i,N){
        int k = mask ^ record[mask];
        int cnt = -1; while(k>0){k>>=1;cnt++;}
        ans.push_back(cnt);
        mask=record[mask];
    }
}
class CompanyMessages
{
        public:
        vector <int> getRank(vector <string> mes)
        {
               M=mes;N=mes.size();
               memset(memo,-1,sizeof(memo));
               solve(two(N)-1);
               cacl();
               return ans;
        }


rikisand 2009-11-22 15:58 发表评论
]]>
SRM 453 div2http://m.shnenglu.com/zqsand/archive/2009/11/18/101316.htmlrikisandrikisandWed, 18 Nov 2009 07:24:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/11/18/101316.htmlhttp://m.shnenglu.com/zqsand/comments/101316.htmlhttp://m.shnenglu.com/zqsand/archive/2009/11/18/101316.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/101316.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/101316.html半夜12Q?0的比赛,开始就发现pȝ很慢Q结果第一题没法提交,然后退出重q退出重q?#183;····server down·····

惌vz的服q没拿,于是跑下d服Q看了会dota vod Q重新登入,比赛竟然l箋·····交了500 开始看1000 没思\Q冻M?/font>

challenge没啥意思,都没人在Q?50的太弱智都对?#183;···׃中间出错Q这ơsrm not rated~~

250 pt 略过

500 pt

John and Brus have an interest in team sports tournaments. They are currently investigating a basketball tournament. Basketball is a team sport in which two teams of five players try to score points against one another by placing a ball through a ten foot high hoop. Basketball is one of the most popular and widely viewed sports in the world.

There are n teams in the tournament. Each pair of teams plays exactly two games against each other. In the first of these games, one of the teams is the host, and in the second, the other team is the host. Each game results in one team winning. There are no draws. After the tournament is over, the team with the highest total number of wins is crowned the winner.

The tournament is currently in progress and the current results are described in the vector <string> table. For each pair of distinct indices, i and j, the j-th character of the i-th element of tableis the result of the game where team i hosted team j. The result is 'W' if team i won, 'L' if team i lost, and '?' if the game hasn't been played yet. Assuming that every possible outcome is possible for the games that haven't been played yet, return the minimal number of total wins the tournament winner can have at the end of the tournament.

Definition

Class:
TheBasketballDivTwo

Method:
find

Parameters:
vector <string>

Returns:
int

Method signature:
int find(vector <string> table)

(be sure your method is public)

Constraints

-
table will contain between 2 and 5 elements, inclusive.

-
Each element of table will contain exactly n characters, where n is the number of elements in table.

-
The j-th character of the i-th element of table, where i and j are different, will be 'W', 'L', or '?'.

-
The i-th character of the i-th element of table will be 'X'.

 

数据量很,扑ֈ未比的比赛场?Q然后枚丑֐U输赢情况,更新解就可以了。或者@?^nơ,或者递归调用

1000 pt

n this tournament, each game results in either a victory for one team or a draw. If a team wins a game, it gains three points and its opponent gains no points. In case of a draw, each team gains one point. The score of a team is the sum of all the points it has gained from all its games. Each pair of teams can play against each other any number of times.

You are given a vector <int> points representing the current standings in the tournament. The i-th element of points is the score of the i-th team. You can assume that the points represent a valid state, i.e., intermediate standings that can be achieved in a tournament according to the rules described above.

Each team will play exactly one more game in the tournament, but it is not known what the matchups will be. After the tournament is over, the teams will be ranked by score. 1st place will go to the team with the highest score, 2nd place will go to the team with the second highest score, and so on. If two teams have the same score, the team with the lower number will place higher. For example, if team 0 and team 3 each have the highest score of 100 points, then team 0 will place 1st and team 3 will place 2nd.

John's favorite team is team 0, and he wants it to place as high as possible. Assuming that the remaining games can be scheduled arbitrarily and can end with any possible outcome, return the highest possible place for team 0 at the end of the tournament.

Definition

Class:
TheSoccerDivTwo

Method:
find

Parameters:
vector <int>

Returns:
int

Method signature:
int find(vector <int> points)

(be sure your method is public)

Constraints

-
points will contain between 2 and 50 elements, inclusive.

-
points will contain an even number of elements.

-
Each element of points will be between 0 and 1,000,000, inclusive.

-
points will represent a valid state.

Examples

Code Snippet
int find(vector <int> p )
{
     int E3=0,A3=0,L3=0,L=0;
     int d=p[0];
     for(int i=1;i<p.size();i++){
        if(p[i]>d+3)A3++;
        else if(p[i]==d+3)E3++;
        else if (p[i]>d)L3++;
        else L++;
     }
     if(A3+L+1>=E3)
         return A3+1;
     return A3+1+(E3-A3-L)/2;
}

 

 

 

因ؓ每队只剩下一场比赛,所以题目变得很单?队最后一轮肯定是取到3分,?队多3Z上比赛的 肯定?队靠前,?队分或者相{的一定在0队之后,剩下的就是我们要考虑的了。如果A3+L+1>=E3 也就是说?队多胜一场的队伍Q如果让他们在最后一轮都输,那么0队可以获得最好成l?A3+1;

然而如果不行剩下的q些E3要有一?E3+1)/2个要得到3分从而比0队高Qover~



rikisand 2009-11-18 15:24 发表评论
]]>
q查?/title><link>http://m.shnenglu.com/zqsand/archive/2009/11/12/100838.html</link><dc:creator>rikisand</dc:creator><author>rikisand</author><pubDate>Thu, 12 Nov 2009 14:03:00 GMT</pubDate><guid>http://m.shnenglu.com/zqsand/archive/2009/11/12/100838.html</guid><wfw:comment>http://m.shnenglu.com/zqsand/comments/100838.html</wfw:comment><comments>http://m.shnenglu.com/zqsand/archive/2009/11/12/100838.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/zqsand/comments/commentRss/100838.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/zqsand/services/trackbacks/100838.html</trackback:ping><description><![CDATA[ <p><strong>昨天看了sedgewick的alg in c 的第一章,主要介绍了个find-union 判断联通的法Q其实用Cq查集的知识</strong></p> <p><strong>刚才偶然看见pojq查集的题集 copyq来自己也写写看~~·</strong></p> <p><strong>慢慢来~~ 写完一道上一道~~</strong></p> <p><strong>       POJ 1182 食物?/strong><br><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1182</a></p> <p><font face="微Y雅黑" color="#83c13e" size="4">q以为是最单的一道呢Q被列在最前面Q原来是扩展的应用,不是那么直接啊~</font></p> <p><font face="微Y雅黑" color="#83c13e" size="4">U结了一会儿Q看了解题报告才有思\。关键是在ƈ查集的基上增加一个数l,l护其与根节点的关系Q?/font></p> <p><font face="微Y雅黑" color="#83c13e" size="4">详情写到注释里面吧:</font></p><pre class="code"><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">A[</span><span style="background: #2b2b2b; color: #ff8080">100003</span><span style="background: #2b2b2b; color: white">][</span><span style="background: #2b2b2b; color: #ff8080">3</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">root[</span><span style="background: #2b2b2b; color: #ff8080">50005</span><span style="background: #2b2b2b; color: white">],k[</span><span style="background: #2b2b2b; color: #ff8080">50005</span><span style="background: #2b2b2b; color: white">];</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: #00ff40">//root记录节点所属于的树木id k记录节点与根的关p? 同类1子是食物2子是天敌 </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">sz[</span><span style="background: #2b2b2b; color: #ff8080">50005</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">find(</span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">x){ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(root[x]==x)</span><span style="background: #2b2b2b; color: #0080ff">return </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">x;//如果是根则返? </span><span style="background: #2b2b2b; color: #0080ff">else if</span><span style="background: #2b2b2b; color: white">(root[root[x]]==root[x])</span><span style="background: #2b2b2b; color: #0080ff">return </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">root[x];//如果W一层,则返? </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">father=root[x]; root[x]=find(father);//攑ֈW一层,减少下次find旉Q减树的高? k[x]=(k[x]+k[father])%</span><span style="background: #2b2b2b; color: #ff8080">3</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;//p׃根的关系以及父节点与根的关系推断出新的自׃根的关系Q实际上是ؓ了解决union后的节点与根的关p?/span></font></font></pre><pre class="code"><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white"> //因ؓunion后,非根节点q没有更新kQ因此需要在此处处理更新 </span><span style="background: #2b2b2b; color: #0080ff">return </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">root[x]; } </span><span style="background: #2b2b2b; color: #0080ff">inline void </span><span style="background: #2b2b2b; color: white">Union(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">x,</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">y,</span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">kind){ </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">a=find(x);</span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><span style="background: #2b2b2b; color: white"><font face="Comic Sans MS" size="2">b=find(y); </font></span><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: #00ff40"> </span><span style="background: #2b2b2b; color: #0080ff">if</span></font></font><span style="background: #2b2b2b; color: white"><font face="Comic Sans MS" size="2">(sz[a]>sz[b]){//判断后决定,要把size的攑ֈsize大的上去Q优化作用不? root[b]=a ; </font></span><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: #00ff40">//b成ؓa的子? </span><span style="background: #2b2b2b; color: white">k[b]=(k[x]-k[y]+kind+</span><span style="background: #2b2b2b; color: #ff8080">3</span><span style="background: #2b2b2b; color: white">)%</span><span style="background: #2b2b2b; color: #ff8080">3</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;//要把b变成a的子树,从a出发Q到xQ经qkindQ到yQ再到b Q可以得到kb的状态改变公? sz[a]+=sz[b];} </span><span style="background: #2b2b2b; color: #0080ff">else</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">{ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(kind==</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">)kind=</span><span style="background: #2b2b2b; color: #ff8080">2</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; root[a]=b; k[a]=(k[y]-k[x]+kind+</span><span style="background: #2b2b2b; color: #ff8080">3</span><span style="background: #2b2b2b; color: white">)%</span><span style="background: #2b2b2b; color: #ff8080">3</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; sz[b]+=sz[a]; } } </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">main() { </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">N,d; freopen(</span><span style="background: #2b2b2b; color: #ff8000">"d:\\input.txt"</span><span style="background: #2b2b2b; color: white">,</span><span style="background: #2b2b2b; color: #ff8000">"r"</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,stdin); scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d"</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,&N,&d); </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">;i<=N;i++)sz[i]=</span><span style="background: #2b2b2b; color: #ff8080">1</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">cnt=</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">s=</span><span style="background: #2b2b2b; color: #ff8080">1</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;s<=N;s++)root[s]=s; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">LIE=</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">while</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">(i !=d) { scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d %d"</span><span style="background: #2b2b2b; color: white">,&A[i][</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">],&A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">],&A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]); </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">]>N || A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span><span style="background: #2b2b2b; color: white">]>N ) {LIE++;i++;</span><span style="background: #2b2b2b; color: #0080ff">continue</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;} </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(A[i][</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">]==</span><span style="background: #2b2b2b; color: #ff8080">1</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">){ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(find(A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">]) == find(A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">])){ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(k[A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">]]!=k[A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]]) LIE++; } </span><span style="background: #2b2b2b; color: #0080ff">else </span><span style="background: #2b2b2b; color: white">Union(A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">],A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span><span style="background: #2b2b2b; color: white">],</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">); } </span><span style="background: #2b2b2b; color: #0080ff">else</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">{ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">( find(A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">])==find(A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span><span style="background: #2b2b2b; color: white">]) ){</span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(k[A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span><span style="background: #2b2b2b; color: white">]] != ( k[A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">]]+</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">)%</span><span style="background: #2b2b2b; color: #ff8080">3</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">)LIE++;} </span><span style="background: #2b2b2b; color: #0080ff">else </span><span style="background: #2b2b2b; color: white">Union(A[i][</span><span style="background: #2b2b2b; color: #ff8080">1</span><span style="background: #2b2b2b; color: white">],A[i][</span><span style="background: #2b2b2b; color: #ff8080">2</span><span style="background: #2b2b2b; color: white">],</span><span style="background: #2b2b2b; color: #ff8080">1</span></font></font><font size="2"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">); } i++; } cout<<LIE<<endl; </span><span style="background: #2b2b2b; color: #0080ff">return </span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><span style="background: #2b2b2b; color: white"><font face="Comic Sans MS" size="2">; }</font></span></pre><a ></a><strong>POJ 1611 The Suspects</strong><br> <p><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1611</a></p> <p><br></p><pre class="code"><span style="background: #2b2b2b; color: white"> </span><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">G[</span><span style="background: #2b2b2b; color: #ff8080">30005</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">sz[</span><span style="background: #2b2b2b; color: #ff8080">30005</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">Find(</span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">x){ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(G[x]==x)</span><span style="background: #2b2b2b; color: #0080ff">return </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">x; </span><span style="background: #2b2b2b; color: #0080ff">else </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">{ </span><span style="background: #2b2b2b; color: #0080ff">while</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">(G[x]!=x){//half路径压羃~{下试试看全压羃的效率~那样是递归调用? </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">t=G[x]; G[x]=G[t]; x=t; } </span><span style="background: #2b2b2b; color: #0080ff">return </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">x; } } </span><span style="background: #2b2b2b; color: #0080ff">void </span><span style="background: #2b2b2b; color: white">Union(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">x,</span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">y){ </span><span style="background: #2b2b2b; color: #0080ff">if</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">(sz[x]<sz[y])swap(x,y);//把size的弄到大的上面 G[y]=x; sz[x]+=sz[y]; } </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">main() { freopen(</span><span style="background: #2b2b2b; color: #ff8000">"d:\\input.txt"</span><span style="background: #2b2b2b; color: white">,</span><span style="background: #2b2b2b; color: #ff8000">"r"</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,stdin); </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">N,M,num; </span><span style="background: #2b2b2b; color: #0080ff">while</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">true</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">){ scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d"</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,&N,&M); </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(N==</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">&&M==</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">)</span><span style="background: #2b2b2b; color: #0080ff">return </span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">;i<N;i++)G[i]=i,sz[i]=</span><span style="background: #2b2b2b; color: #ff8080">1</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;i<M;i++){ scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d"</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,&num); </span><span style="background: #2b2b2b; color: #0080ff">int </span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">root,stu,x,y; </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">j=</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">;j<num;j++){ scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d"</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">,&stu); </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(j==</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">)root=Find(stu);//单的都和W一个合q? </span><span style="background: #2b2b2b; color: #0080ff">else</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">{ root=Find(root); x=Find(stu);</span><span style="background: #2b2b2b; color: #0080ff">if</span></font></font><font size="4"><font face="Comic Sans MS"><span style="background: #2b2b2b; color: white">(root!=x)Union(root,x); } } } printf(</span><span style="background: #2b2b2b; color: #ff8000">"%d\n"</span><span style="background: #2b2b2b; color: white">,sz[Find(</span><span style="background: #2b2b2b; color: #ff8080">0</span></font></font><span style="background: #2b2b2b; color: white"><font face="Comic Sans MS" size="4">)]); } }</font></span></pre> <p><a ></a><strong>POJ 2524 Ubiquitous Religions</strong></p> <p><strong>又一道水题~~ 呵呵  </strong></p> <p><strong>不脓(chung)代码?和上面一道基本一样~</strong><br><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=2524</a></p> <p><font size="2"><strong>POJ 1861</strong></font></p> <p><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1861</a></p> <p><font size="2"><strong>kruskal+q查?half路径压羃</strong></font></p> <p><strong><font size="2">比较基础的题</font></strong></p><pre class="code"><span style="background: #2b2b2b; color: #0080ff"><font face="Comic Sans MS" size="4"><em>struct </em></font></span><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">Edge{ </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">from; </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">to; </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">value; }E[</span><span style="background: #2b2b2b; color: #ff8080">15000</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">A[</span><span style="background: #2b2b2b; color: #ff8080">1005</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">sz[</span><span style="background: #2b2b2b; color: #ff8080">2009</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">]; </span><span style="background: #2b2b2b; color: #0080ff">bool </span><span style="background: #2b2b2b; color: white">comp(</span><span style="background: #2b2b2b; color: #0080ff">const </span><span style="background: #2b2b2b; color: white">Edge& a,</span><span style="background: #2b2b2b; color: #0080ff">const </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">Edge& b){ </span><span style="background: #2b2b2b; color: #0080ff">return </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">a.value<b.value; } </span><span style="background: #2b2b2b; color: #0080ff">using namespace </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">std; </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">Find(</span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">x){ </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(A[x]==x)</span><span style="background: #2b2b2b; color: #0080ff">return </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">x; </span><span style="background: #2b2b2b; color: #0080ff">else if</span><span style="background: #2b2b2b; color: white">(A[A[x]]==A[x]) </span><span style="background: #2b2b2b; color: #0080ff">return </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">A[x]; </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">father; </span><span style="background: #2b2b2b; color: #0080ff">while</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">(A[x]!=x){ father=A[x]; A[x]=A[father];//把每一个\q的节点攑ֈ父下面? x=father; } </span><span style="background: #2b2b2b; color: #0080ff">return </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">x; } </span><span style="background: #2b2b2b; color: #0080ff">void </span><span style="background: #2b2b2b; color: white">Union(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">x,</span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">y){ </span><span style="background: #2b2b2b; color: #0080ff">if</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">(sz[y]>sz[x])swap(x,y);//的攑ֈ大的下面 sz[x]+=sz[y]; A[y]=x; } </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">main() { freopen(</span><span style="background: #2b2b2b; color: #ff8000">"d:\\input.txt"</span><span style="background: #2b2b2b; color: white">,</span><span style="background: #2b2b2b; color: #ff8000">"r"</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">,stdin); </span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">N,M,num,x,y; scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d"</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">,&N,&M); </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">cnt=</span><span style="background: #2b2b2b; color: #ff8080">0</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">while</span><span style="background: #2b2b2b; color: white">(cnt<M) scanf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d %d"</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">,&E[cnt].from,&E[cnt].to,&E[cnt].value),cnt++; sort(E,E+M,comp);//从小到大选n-1条边Q如果v点和l点在一个集合则continueQelse Union </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">;i<=N;i++)sz[i]=</span><span style="background: #2b2b2b; color: #ff8080">1</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">,A[i]=i; vector<</span><span style="background: #2b2b2b; color: #0080ff">int</span><span style="background: #2b2b2b; color: white">> ans(N-</span><span style="background: #2b2b2b; color: #ff8080">1</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">); </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">mst=</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">,MX=</span><span style="background: #2b2b2b; color: #ff8080">0</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">; </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">;mst!=N-</span><span style="background: #2b2b2b; color: #ff8080">1</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">;i++){ </span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">x=Find(E[i].from);</span><span style="background: #2b2b2b; color: #0080ff">int </span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">y=Find(E[i].to); </span><span style="background: #2b2b2b; color: #0080ff">if</span><span style="background: #2b2b2b; color: white">(x==y)</span><span style="background: #2b2b2b; color: #0080ff">continue</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">; Union(x,y); ans[mst]=i; mst++; </span><span style="background: #2b2b2b; color: #0080ff">if</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">(E[i].value>MX)MX=E[i].value; } printf(</span><span style="background: #2b2b2b; color: #ff8000">"%d\n%d\n"</span><span style="background: #2b2b2b; color: white">,MX,N-</span><span style="background: #2b2b2b; color: #ff8080">1</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">); </span><span style="background: #2b2b2b; color: #0080ff">for</span><span style="background: #2b2b2b; color: white">(</span><span style="background: #2b2b2b; color: #0080ff">int </span><span style="background: #2b2b2b; color: white">i=</span><span style="background: #2b2b2b; color: #ff8080">0</span><span style="background: #2b2b2b; color: white">;i<N-</span><span style="background: #2b2b2b; color: #ff8080">1</span></em></font></font><font size="4"><font face="Comic Sans MS"><em><span style="background: #2b2b2b; color: white">;i++) printf(</span><span style="background: #2b2b2b; color: #ff8000">"%d %d\n"</span></em></font></font><span style="background: #2b2b2b; color: white"><font face="Comic Sans MS" size="4"><em>,E[ans[i]].from,E[ans[i]].to); }</em></font></span></pre><a ></a> <p><br> <strong>       POJ 1456 Supermarket</strong><br><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1456</a><br> </p> <p><strong>       POJ 1733 Parity game</strong><br><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1733</a><br>  </p><p><strong>       hdu 3038 How Many Answers Are Wrong</strong><br><a >http://acm.hdu.edu.cn/showproblem.php?pid=3038</a><br>  </p><p><strong>     POJ 1417 True Liars(?</strong><br><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=1417</a><br>  </p><p><strong>   POJ 2912 Rochambeau(?</strong> </p><p><a >http://acm.pku.edu.cn/JudgeOnline/problem?id=2912</a></p><img src ="http://m.shnenglu.com/zqsand/aggbug/100838.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/zqsand/" target="_blank">rikisand</a> 2009-11-12 22:03 <a href="http://m.shnenglu.com/zqsand/archive/2009/11/12/100838.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TC-srm249-Tableseat-DP-状态排?/title><link>http://m.shnenglu.com/zqsand/archive/2009/11/12/100835.html</link><dc:creator>rikisand</dc:creator><author>rikisand</author><pubDate>Thu, 12 Nov 2009 13:45:00 GMT</pubDate><guid>http://m.shnenglu.com/zqsand/archive/2009/11/12/100835.html</guid><wfw:comment>http://m.shnenglu.com/zqsand/comments/100835.html</wfw:comment><comments>http://m.shnenglu.com/zqsand/archive/2009/11/12/100835.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/zqsand/comments/commentRss/100835.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/zqsand/services/trackbacks/100835.html</trackback:ping><description><![CDATA[ <p>Your restaurant has <strong>numTables</strong> tables to seat customers. The tables are all arranged in a line. If a large party of customers comes in, a group of adjacent tables will be used. Which group of tables is entirely up to the customer. Since you cannot predict this, assume all possible choices occur with equal probability. What you can predict is the size of each group of customers that arrives. Element i of <strong>probs</strong> gives the probability, in percent, that an entering party will need i+1 tables. Assuming nobody leaves, return the expected number of tables you will use before a party must be turned away. This only occurs if there is no place to seat them. </p><h5>Method signature:<br>double getExpected(int numTables, vector <int> probs)</h5> <p><strong>numTables</strong> will be between 1 and 12 inclusive.<br><strong>probs</strong> will contain between 1 and 12 elements inclusive.<br>Each element of <strong>probs</strong> will be between 0 and 100 inclusive.<br>The elements of <strong>probs</strong> will sum to 100. </p><p>  </p><p><font face="微Y雅黑" color="#008080" size="4">misof 数字表达教程里的习题~ 题目大意 求用桌子的期望。由于到来group的个C定,每个group需要的桌子不定Qɼ定期望变得困难。但考虑对于numTables来说,使用桌子的状态仅仅有 2^numTablesU,因此考虑在这些状态改变的q程中来计算期望Q也是计算在每个状态下面的期望桌子数目。在每个状态到达时Q依ơ考虑来了一个group需要k个位子,如果rU安排可以满k个位子,那么当前状态的期望D加上 来k个位子的概率 X QrU安排分别的期望?/ rQ?其中求r中安排期望和则需?递归调用函数。显然利用memo可以减少重复计算于是有下面的解法Q?/font> </p><p><font face="Comic Sans MS" size="2">vector<double> p;<br>double dp[1<<13];    <br>int tb;<br>double solve(int cur){<br>    if(dp[cur]>-1.0)return dp[cur];    //memo available<br>    double ret=0;double sum;int kind;<br>    for(int i=0;i<p.size();i++){<br>        sum=0,kind=0;<br>        int mask=(1<<(i+1))-1;    //new group need i+1 adjacent tables<br>        for(int j=0;j+i+1<=tb;j++){<br>            if((cur&(mask<<j))==0){    //current pattern could meet the need<br>                sum+=solve(cur+(mask<<j))+i+1;    //total method ++<br>                kind++; <br>            }<br>        }<br>        if(kind!=0)sum/=kind; //caculate the average need<br>        ret+=sum*p[i];<br>    }<br>    dp[cur]=ret;<br>    return ret;<br>}</font> </p><p><font face="Comic Sans MS" size="2">        double getExpected(int numTables, vector <int> probs)<br>        {<br>                tb=numTables;<br>                REP(i,1<<13)dp[i]=-1.0;<br>                p.resize(probs.size());<br>                for(int i=0;i<probs.size();i++)p[i]=probs[i]*0.01;<br>                return solve(0);//the beginning pattern<br>        }</font> </p><p><font color="#ff8040" size="3">看比赛中有另一U解法,x据题目,在到达每ơfail to serve a group 的时?Ҏ(gu)此时的桌子数量,和到达这U状态的概率 来计:</font></p> <p><font color="#ff8040" size="3">dp[1<<13][15];memset(dp,0,sizeof(dp));// :D lucily I can do this for 0 </font></p> <p><font color="#ff8040" size="3">double fails=0.0;bool flag ;</font></p> <p><font color="#ff8040" size="3">for(int i=1;i<=numTables+1;i++)  //循环最多numTables+1 ?/font></p> <p><font color="#ff8040" size="3">{flag=true;</font></p> <blockquote> <p><font color="#ff8040" size="3">for(int j=0;j<p.size();j++){</font></p> <p><font color="#ff8040" size="3">     int mask=(1<<(j+1))-1;//注意UMq算W的优先U低,注意加括?/font></p> <p><font color="#ff8040" size="3">     for(int k=0;k<=(1<<numTables-1);k++){</font></p> <p><font color="#ff8040" size="3">          if(dp[k][i-1]<=0.0)continue;</font></p> <p><font color="#ff8040" size="3">          flag=false;</font></p> <p><font color="#ff8040" size="3">          int cnt=0;</font></p> <p><font color="#ff8040" size="3">          for(int m=0;m+j+1<=numTables;m++) if((mask<<m)&k==0)cnt++;</font></p> <p><font color="#ff8040" size="3">          if(cnt)for(int m=0;m+j+1<=numTables;m++)if((mask<<m)&k==0)dp[mask<<m|k][i]+=dp[k][i-1]*p[j]/cnt;</font></p> <p><font color="#ff8040" size="3">          if(!cnt){</font></p> <p><font color="#ff8040" size="3">                 int b=k,bn=0;while(b){if(b&1)bn++;b>>=1;}</font></p> <p><font color="#ff8040" size="3">                 fail+=dp[k][i-1]*bn;  </font></p> <p><font color="#ff8040" size="3">         }</font></p> <p><font color="#ff8040" size="3">    }</font></p> <p><font color="#ff8040" size="3">}</font></p> <p><font color="#ff8040" size="3">if(flag)return fail;//all dp[][k]==0.0</font></p></blockquote> <p><font color="#ff8040" size="3">}</font></p> <p><font color="#ff8040" size="3">return fail;</font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font color="#ff8040" size="3">优先U很Ҏ(gu)错:</font></p> <p><a ><font color="#ff8040">http://www.cppreference.com/wiki/operator_precedence</font></a><font color="#ff8040" size="3">~。~</font></p> <p><font color="#ff8040" size="3">典型的几?/font></p> <p><font color="#ff8040" size="3">++ -- <post-incre-decre></font></p> <p><font color="#ff8040" size="3">~ <bitwise complement> !<not>&<addresss> *<dereference>&<address></font></p> <p><font color="#ff8040" size="3">*  / % </font></p> <p><font color="#ff8040" size="3">+ -</font></p> <p><font color="#ff8040" size="3">>>  <<</font></p> <p><font color="#ff8040" size="3">< <= > >=</font></p> <p><font color="#ff8040" size="3">== !=</font></p> <p><font color="#ff8040" size="3">&</font></p> <p><font color="#ff8040" size="3">^ xor</font></p> <p><font color="#ff8040" size="3">|</font></p> <p><font color="#ff8040" size="3">&&</font></p> <p><font color="#ff8040" size="3">||</font></p> <p><font color="#ff8040" size="3">?=</font></p> <p><font color="#ff8040" size="3">= += –= <<= >>=</font></p> <p><font color="#ff8040" size="3">,</font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font color="#ff8040" size="3">从上C依次降低~~~~~~~~~~~~~~~~~~··</font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#ff8040"> </font></p> <p><font size="3"></font><font color="#800000"> </font></p> <p><font color="#0000ff" size="3"></font></p><img src ="http://m.shnenglu.com/zqsand/aggbug/100835.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/zqsand/" target="_blank">rikisand</a> 2009-11-12 21:45 <a href="http://m.shnenglu.com/zqsand/archive/2009/11/12/100835.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://m.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.xvjw.cn" target="_blank">þþƷۺ</a>| <a href="http://www.xyp020.cn" target="_blank">ƷѾþ</a>| <a href="http://www.f-lover.cn" target="_blank">˾þô߽ۺAv</a>| <a href="http://www.3-gold.cn" target="_blank">ҹҹݺݾþAV</a>| <a href="http://www.zjhongfeng.cn" target="_blank">þþһƷ99þþƷ88</a>| <a href="http://www.517down.cn" target="_blank">þ99Ʒ鶹</a>| <a href="http://www.emsyx.cn" target="_blank">þ97þ97Ʒӿϼ</a>| <a href="http://www.hygaiye.cn" target="_blank">ۺϾþþƷ</a>| <a href="http://www.woool-woool.com.cn" target="_blank">þAV˳׽</a>| <a href="http://www.wzwsbz.cn" target="_blank">㽶þһ޶ӰԺ</a>| <a href="http://www.ai385.cn" target="_blank">ۺϾþҹAV </a>| <a href="http://www.theys.cn" target="_blank">99þþƷһ</a>| <a href="http://www.foxconm.cn" target="_blank">պþӰԺ</a>| <a href="http://www.b42k.cn" target="_blank">ݺɫۺվþþþþþø </a>| <a href="http://www.enld.cn" target="_blank">ƷþþþӰԺɫ</a>| <a href="http://www.hdtnet.cn" target="_blank">þŷ޹ۺ</a>| <a href="http://www.pajiangxing.com.cn" target="_blank">ٸƷþþһ</a>| <a href="http://www.mabcrea.cn" target="_blank">þþþƷҰ</a>| <a href="http://www.51jintianfang.cn" target="_blank">ŷ糱þþXXXXx</a>| <a href="http://www.t8s.com.cn" target="_blank">ձƷþþþӰԺձ</a>| <a href="http://www.0553fc.cn" target="_blank">www.þ</a>| <a href="http://www.lntyyp.cn" target="_blank">þþƷ99þ޶ </a>| <a href="http://www.zgyjj.cn" target="_blank">ھƷþ</a>| <a href="http://www.0379f.cn" target="_blank">ձƷþþþӰԺձ</a>| <a href="http://www.hiinterface.cn" target="_blank">777þµַ</a>| <a href="http://www.z-yh.cn" target="_blank">뾫ƷþþӰ</a>| <a href="http://www.aboto.cn" target="_blank">þɫۺ</a>| <a href="http://www.omsai.cn" target="_blank">þþۺϾɫۺϾ</a>| <a href="http://www.zl6688.com.cn" target="_blank">99þۺϾƷվ</a>| <a href="http://www.lpnppddrppp.cn" target="_blank">ղƷ99þþþþ</a>| <a href="http://www.mxcqsf.cn" target="_blank">99ξþþŷƷվ</a>| <a href="http://www.gofiv.cn" target="_blank">þþþþþþŮ</a>| <a href="http://www.iteethle.cn" target="_blank">ƷۺרƬþþ </a>| <a href="http://www.hzskc.cn" target="_blank">ղƷþþһ</a>| <a href="http://www.xitie520.cn" target="_blank">һþþƷһ</a>| <a href="http://www.kygg.net.cn" target="_blank">㽶aaþëƬ</a>| <a href="http://www.msn56.cn" target="_blank">ŷۺϾþͼƬ</a>| <a href="http://www.gmyk.net.cn" target="_blank">˺ݺۺϾþ</a>| <a href="http://www.tianlaiedu.cn" target="_blank">AŮAVۺϾþþ</a>| <a href="http://www.jingxi.jx.cn" target="_blank">ձƷþþþþþþ</a>| <a href="http://www.tonyifu.cn" target="_blank">ҹƵþþþһ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>