??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久国产精品人妻,一本久久a久久精品综合香蕉,日本免费久久久久久久网站http://www.shnenglu.com/notonlysuccess/ACMzh-cnFri, 09 May 2025 11:06:19 GMTFri, 09 May 2025 11:06:19 GMT60新博?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/11/16/101134.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Mon, 16 Nov 2009 11:45:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/11/16/101134.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/101134.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/11/16/101134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/101134.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/101134.html</trackback:ping><description><![CDATA[<a >notonlysuccess</a><br><br><br>q个博客不用了,一些还好的资料?x)慢慢搬到新博?br>谢谢朋友们l关?br><br> <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/101134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-11-16 19:45 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/11/16/101134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>旉一时http://www.shnenglu.com/notonlysuccess/archive/2009/09/10/95805.htmlshǎ?/dc:creator>shǎ?/author>Thu, 10 Sep 2009 07:13:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/09/10/95805.htmlhttp://www.shnenglu.com/notonlysuccess/comments/95805.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/09/10/95805.html#Feedback0http://www.shnenglu.com/notonlysuccess/comments/commentRss/95805.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/95805.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=2494

Elevator Simulation
http://acm.hdu.edu.cn/showproblem.php?pid=1386

Tetris
http://acm.hdu.edu.cn/showproblem.php?pid=3013

Gates of Logic
http://acm.hdu.edu.cn/showproblem.php?pid=1886

Teacher YYF
http://acm.pku.edu.cn/JudgeOnline/problem?id=3746

中国象棋II
http://acm.fzu.edu.cn/problem.php?pid=1694

Typesetting
http://acm.hdu.edu.cn/showproblem.php?pid=2718

Connect
http://acm.hdu.edu.cn/showproblem.php?pid=2727

Hex Tile Equations
http://acm.hdu.edu.cn/showproblem.php?pid=2702

HTML Wrapper
http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=4083


]]>
Asia Regional Contesthttp://www.shnenglu.com/notonlysuccess/archive/2009/08/19/93817.htmlshǎ?/dc:creator>shǎ?/author>Wed, 19 Aug 2009 05:35:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/08/19/93817.htmlhttp://www.shnenglu.com/notonlysuccess/comments/93817.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/08/19/93817.html#Feedback0http://www.shnenglu.com/notonlysuccess/comments/commentRss/93817.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/93817.html

]]>
PKU——DP专辑http://www.shnenglu.com/notonlysuccess/archive/2009/07/29/91589.htmlshǎ?/dc:creator>shǎ?/author>Wed, 29 Jul 2009 07:18:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/07/29/91589.htmlhttp://www.shnenglu.com/notonlysuccess/comments/91589.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/07/29/91589.html#Feedback4http://www.shnenglu.com/notonlysuccess/comments/commentRss/91589.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/91589.html1042 Gone Fishing
1062 昂贵的聘C?br>1074 Parallel Expectations
1093 Formatting Text
1112 Team Them Up!
1143 Number Game
1160 Post Office
1178 Camelot
1179 Polygon
1180 Batch Scheduling
1187 陨石的秘?br>1189 钉子和小?br>1191 盘分割
1192 最优连通子?br>1208 The Blocks Problem
1239 Increasing Sequences
1240 Pre-Post-erous!
1293 Duty Free Shop
1322 Chocolate
1390 Blocks
1414 Life Line
1432 Decoding Morse Sequences
1475 Pushing Boxes
1485 Fast Food
1505 Copying Books
1513 Scheduling Lectures
1609 Tiling Up Blocks
1633 Gladiators
1635 Subway tree systems
1636 Prison rearrangement
1644 To Bet or Not To Bet
1649 Market Place
1655 Balancing Act
1661 Help Jimmy
1664 放苹?br>1671 Rhyme Schemes
1682 Clans on the Three Gorges
1690 (Your)((Term)((Project)))
1692 Crossed Matchings
1695 Magazine Delivery
1699 Best Sequence
1704 Georgia and Bob
1707 Sum of powers
1712 Flying Stars
1714 The Cave
1717 Dominoes
1718 River Crossing
1722 SUBTRACT
1726 Tango Tango Insurrection
1732 Phone numbers
1733 Parity game
1737 Connected Graph
1740 A New Stone Game
1742 Coins
1745 Divisibility
1770 Special Experiment
1771 Elevator Stopping Plan
1776 Task Sequences
1821 Fence
1837 Balance
1848 Tree
1850 Code
1853 Cat
1874 Trade on Verweggistan
1889 Package Pricing
1920 Towers of Hanoi
1926 Pollution
1934 Trip
1936 All in All
1937 Balanced Food
1946 Cow Cycling
1947 Rebuilding Roads
1949 Chores
1952 BUY LOW, BUY LOWER
1958 Strange Towers of Hanoi
1959 Darts
1962 Corporative Network
1975 Median Weight Bead
1989 The Cow Lineup
2018 Best Cow Fences
2019 Cornfields
2029 Get Many Persimmon Trees
2033 Alphacode
2047 Concert Hall Scheduling
2063 Investment
2081 Recaman's Sequence
2082 Terrible Sets
2084 Game of Connections
2127 Greatest Common Increasing Subsequence
2138 Travel Games
2151 Check the difficulty of problems
2152 Fire
2161 Chandelier
2176 Folding
2178 Heroes Of Might And Magic
2181 Jumping Cows
2184 Cow Exhibition
2193 Lenny's Lucky Lotto Lists
2231 Moo Volume
2279 Mr. Young's Picture Permutations
2287 Tian Ji -- The Horse Racing
2292 Optimal Keypad
2329 Nearest number - 2
2336 Ferry Loading II
2346 Lucky tickets
2353 Ministry
2355 Railway tickets
2356 Find a multiple
2374 Fence Obstacle Course
2378 Tree Cutting
2384 Harder Sokoban Problem
2392 Space Elevator
暴力三层循环
2397 Spiderman
2414 Phylogenetic Trees Inherited
2424 Flo's Restaurant
2430 Lazy Cows
2915 Zuma
3017 Cut the Sequence
3028 Shoot-out
3124 The Bookcase
3176 Cow Bowling
3133 Manhattan Wiring
3345 Bribing FIPA
3375 Network Connection




]]>
状态DP~http://www.shnenglu.com/notonlysuccess/archive/2009/07/12/89874.htmlshǎ?/dc:creator>shǎ?/author>Sun, 12 Jul 2009 08:40:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/07/12/89874.htmlhttp://www.shnenglu.com/notonlysuccess/comments/89874.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/07/12/89874.html#Feedback0http://www.shnenglu.com/notonlysuccess/comments/commentRss/89874.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/89874.htmlhttp://acm.sgu.ru/problem.php?contest=0&problem=222
q是入门题,数据较大Q需要记忆化搜烦(ch)

http://acm.pku.edu.cn/JudgeOnline/problem?id=1321
上题的提高版Q不q数据超,爆搜都能q?br>
http://acm.sgu.ru/problem.php?contest=0&problem=223
先要预处理出一行中的全部可行状态~
然后DP的时候y妙的q用位运进行状态的判断和{U?br>状态dp中位q算的y妙运用会(x)大幅度提高程序的效率和帅气程?br>
http://acm.pku.edu.cn/JudgeOnline/problem?id=1185
非常l典的状态DPQ由于攻击范围是两格Q所以要保持两个状态,有h用三q制压羃Q我觉得太烦(ch)?不能使用飘逸的位运)(j)
但是[101][2^10][2^10]得状态太大,考虑?^10中有很多情况是不可到辄
计算下当m=10的时候最?0个合法状态,所以我开了[101][60][60]的数l记忆化DPq了

http://acm.hdu.edu.cn/showproblem.php?pid=2640
teddy大牛的题目,和上题差不多Q不q不能重叠放Q所以处理比上题?ch)很?br>同样2^8里有很多不可到达的情况,最多之?3U?br>所以我开[101][13][13]的数l?5msp了,哈哈
q就好像?span style="color: red;">两次状态压~?/span>
最q的DP题目感觉?span style="color: red;">把很多不可到辄状态压~掉效率?x)提高超多~也可能让E序从TLE MLE变成AC~

http://acm.pku.edu.cn/JudgeOnline/problem?id=2411
http://acm.hdu.edu.cn/showproblem.php?pid=1400
q道其实很简单,先预处理出当前状态s1C一状态的可能值s2Qhash[1<<m,1<<m]记录Qm?yu)?br>dp[0][(1<<m)-1] = 1
然后l过n*(1<<m)*(1<<m)的@环得出结果dp[n][(1<<m)-1]

http://acm.sgu.ru/problem.php?contest=0&problem=223
两种砖块Q除了预处理的时候状态多点,?U分支,其他的都和上一题一?br>(L一个状态到另一个状态可能会(x)有多U情况,hash的时候要?+而不是true false)

http://acm.hdu.edu.cn/showproblem.php?pid=2280
要求用最的1铺满所有的I格Q其?是没用的(可以用两?代替)Q化之后使用的方块和上一题一P一L(fng)预处理后
dp求出最的1

http://acm.pku.edu.cn/JudgeOnline/problem?id=1038
http://acm.hdu.edu.cn/showproblem.php?pid=2696
http://acm.hdu.edu.cn/showproblem.php?pid=2442
http://acm.hdu.edu.cn/showproblem.php?pid=1755
http://acm.hdu.edu.cn/showproblem.php?pid=1820
http://acm.hdu.edu.cn/showproblem.php?pid=1668
http://acm.hdu.edu.cn/showproblem.php?pid=2518
http://acm.hdu.edu.cn/showproblem.php?pid=1666
http://acm.hdu.edu.cn/showproblem.php?pid=1820
http://acm.hdu.edu.cn/showproblem.php?pid=2315


]]>
奇的舞y~~Dancing_Linkshttp://www.shnenglu.com/notonlysuccess/archive/2009/07/10/89701.htmlshǎ?/dc:creator>shǎ?/author>Thu, 09 Jul 2009 17:17:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/07/10/89701.htmlhttp://www.shnenglu.com/notonlysuccess/comments/89701.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/07/10/89701.html#Feedback13http://www.shnenglu.com/notonlysuccess/comments/commentRss/89701.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/89701.htmlhttp://sqybi.com/works/dlxcn/
惊讶于它做深搜的时候可以达到如此强劲的剪枝
下午的时候不看网上的模板自己写了一个,自认为是比模板少了一个for循环Q但是写好后才发现没有模板的启发式搜索的效率Q就q样zȝ生的TLE了,费了我好几个小时啊~~%>_<%~~
晚上只好写用模板的方法,写了一个后瞬间q了Q感觉难度也不过?dng)?br>但这个舞y链可是Ҏ(gu)解答却很隄出的主,构造舞y链q是关键
献上我的模板~~
最单的舞蹈链,效率仅比hhanger差,可以?40MS,不过后来我测Z一些数据的l构Q暴力优化到?24MSQ哈哈哈(得意一?~~~
http://acm.hust.edu.cn/thanks/problem.php?id=1017
(_覆盖问题)
void remove(int &c) {
    L[R[c]] 
= L[c];
    R[L[c]] 
= R[c];
    
for(int i = D[c]; i != c ; i = D[i]) {
        
for(int j = R[i]; j != i ; j = R[j]) {
            U[D[j]] 
= U[j];
            D[U[j]] 
= D[j];
            
--S[Col[j]];
        }
    }
}
void resume(int &c) {
    
for(int i = U[c];i != c;i = U[i]) {
        
for(int j = L[i]; j != i ; j = L[j]) {
            
++S[Col[j]];
            U[D[j]] 
= j;
            D[U[j]] 
= j;
        }
    }
    L[R[c]] 
= c;
    R[L[c]] 
= c;
}
bool dfs() {
    
if(R[0== 0) {
        return true;
    }
    
int i , j;
    
int idx,minnum = 999999;
    
for(i = R[0];i != 0 ; i = R[i]) {
        
if(S[i] < minnum) {
            minnum 
= S[i];
            idx 
= i;
        }
    }
    remove(idx);
    
for(i = D[idx]; i != idx; i = D[i]) {
        ans[deep
++= Row[i];
        
for(j = R[i]; j != i ; j = R[j]) {
            remove(Col[j]);
        }
        
if(dfs()) {
            
return true;
        }
        deep 
--;
        
for(j = L[i]; j != i ; j = L[j]) {
            resume(Col[j]);
        }
    }
    resume(idx);
    
return false;
}
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3209
(_覆盖问题)
大的这道省赛题其实是完美覆盖的{化~把每一格都分开来,要求是选N个方块把囑֮覆盖全部搜完然后最的个数
思\Q行方块Q列单位格子,矩阵?是方块所能覆盖的格?br>
http://acm.nuaa.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1507
(重复覆盖问题) 重复覆盖的模杉K
献上模板
void remove(int &c) {
    for(int i = D[c]; i != c ; i = D[i]) {
        L[R[i]] = L[i];
        R[L[i]] = R[i];
    }
}
void resume(int &c) {
    for(int i = U[c]; i != c ; i = U[i]) {
        L[R[i]] = i;
        R[L[i]] = i;
    }
}
int h() {
    bool hash[51];
    memset(hash,false,sizeof(hash));
    int ret = 0;
    for(int c = R[0]; c != 0 ; c = R[c]) {
        if(!hash[c]) {
            ret ++;
            hash[c] = true;
            for(int i = D[c] ; i != c ; i = D[i]) {
                for(int j = R[i] ; j != i ; j = R[j]) {
                    hash[Col[j]] = true;
                }
            }
        }
    }
    return ret;
}
bool dfs(int deep,int lim) {
    if(deep + h() > lim) {
        return false;
    }
    if(R[0] == 0) {
        return true;
    }
    int idx , i , j , minnum = 99999;
    for(i = R[0] ; i != 0 ; i = R[i]) {
        if(S[i] < minnum) {
            minnum = S[i];
            idx = i;
        }
    }
    for(i = D[idx]; i != idx; i = D[i]) {
        remove(i);
        for(j = R[i]; j != i ; j = R[j]) {
            remove(j);
        }
        if(dfs(deep+1,lim)) {
            return true;
        }
        for(j = L[i]; j != i ; j = L[j]) {
            resume(j);
        }
        resume(i);
    }
    return false;
}

http://acm.tju.edu.cn/acm/showp3219.html
http://acm.hdu.edu.cn/showproblem.php?pid=2295
(重复覆盖问题)
q题无法转化成完覆盖,所以remove和resume的时候要变化一下,但是q样q是?x)超时我看了标程才算AC。唉。?br>主要是里边的一个A*的h函数是在是太犀利了Q一下从TLEC46MS。。。。剪枝还是非帔R要的
思\Q行是雷达,列是城市(jng)Q矩阵中1是雷达覆盖城?br>
http://acm.fzu.edu.cn/problem.php?pid=1686
(重复覆盖问题)
q道题也同上道一hQ??-1矩阵中选取最的行,使得每一列最有一?" q个模型
所以和上一道徏表一样徏好之后套上模板就AC了~
思\Q行是枚丑֜每个位子N法,列式怪物个数(最好给怪物标记个id)Q矩阵中?是在q个地方N法是否能辑ֈ目标怪物

http://www.spoj.pl/problems/NQUEEN/
(重复覆盖问题)
N皇后问题Q打的时候没能想到怎么转化成精覆盖,只是用了dancing links的思想Q傻?c)׃一个晚上完成了一个超U复杂的c_型链?重复覆盖)Q开始的时候启发式函数S没有更新Q导致没有发挥效用,l果本例30?的数据都跑不出来Q还以ؓ(f)是想法出错了Q睡觉前在床上想刎ͼ改了一下,效率呈指数增长Q?0?的瞬间跑出来Q在state里排到第一Q哈?br>
(_覆盖问题)
今天CH教我怎么之转化成十字链表的_覆盖Q但是矩阉|(n*n)*(6*n-2)比米字型链表n*n的大了好多倍,交了一下,跑了1sQ效率不如米字型?br>其思\是:(x)行是格子数n*n,列是(??正逆对角线)Q矩阵中?是放在各自上所占得行,列,对角U?br>不需要全部搜完,只要初始皇后+dfs的深度达到n(放了n个皇?return true

http://acm.hdu.edu.cn/showproblem.php?pid=2828
(_覆盖问题)
q题恶化N皇后一样可以{化成多种覆盖。我是精覆盖,列是n+m只要_前n个就够了
(重复覆盖问题)
q可以{化成不精,那么列就是n

当然Q此题出题h的意图是二分匚w。。?br>
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=31
http://acm.pku.edu.cn/JudgeOnline/problem?id=1084
(重复覆盖问题)
q题要不和我说是dancing links 我还真看不出?br>此题烦(ch)Q虽看出来但是徏表就׃我一个半时Q还q我使用上行的头节点Q以前我只是用列的头节点Q努力了很久Q过了sampleAC了,?ch)就烦(ch)在?br>思\Q行是火柴棒敎ͼ列是完美时能构成的矩阉|目,矩阵中的1是列矩阵是否包含行火?br>
http://acm.pku.edu.cn/JudgeOnline/problem?id=3074
http://acm.pku.edu.cn/JudgeOnline/problem?id=3076
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3038
(_覆盖问题)
l典的数独,看了论文才明白怎么覆盖Q?*9*9的行 (9+9+9)*9+9*9的列
思\Q行?1个小?每个格子?个可能数字,列是81个小?9??块?个数?br>每列切的有4?
开始读入的时候吧定的数字的头上?删掉可以很大的提高效?br>
http://acm.hdu.edu.cn/showproblem.php?pid=2518
爽的dancing links
q题所有的方块可以旋{Q这点超?ch)~
我差点就代码了,枚D所有状态,不过最后我q是修改成不的办?br>只有几组{案Q用dancing links暴力跑出所有组合后然后打表Q嘿嘿,我就是这么猥琐的q的
72*所有摆放数~
思\Q?0个格子加12个方块作为列Q所有摆攄Ҏ(gu)C


好了QA光上q题目dancing links的学?fn)也告一D落Q这个舞y是在是优美Q以后出题一定要׃曲经典的舞蹈~~



2009.9.6
发现dancing linksq能?span style="color: red;">最大团
http://acm.hdu.edu.cn/showproblem.php?pid=1530
转化成补囑֐再徏表。。。不q效率很低,跑了6000+MSQ全部搜完找一个最大的Q还没有更优的办法优化,试q二分再写个h函数未果。。?br>
10.15
http://acm.hdu.edu.cn/showproblem.php?pid=3156
和雷辄|不过放radar的点要求出来Q也是先二分枚D半径Q然后利用两个点和半径确定一个圆心C(n,2)Q可以证明如果放其他地方一定没q个圆心?br>

]]>
hdu1055 & PKU2054------DP+可以L取出节点的二叉堆http://www.shnenglu.com/notonlysuccess/archive/2009/06/29/88793.htmlshǎ?/dc:creator>shǎ?/author>Mon, 29 Jun 2009 08:30:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/06/29/88793.htmlhttp://www.shnenglu.com/notonlysuccess/comments/88793.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/06/29/88793.html#Feedback3http://www.shnenglu.com/notonlysuccess/comments/commentRss/88793.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/88793.htmlhttp://acm.pku.edu.cn/JudgeOnline/problem?id=2054
http://acm.hdu.edu.cn/showproblem.php?pid=1055
好点l典的一道题目,做了半天都做不出?br>后来到网上看了解题报告才明白Q解题报告网上有Q我׃再出说明了)(j)是n^2的算?br>我在惻I每次都遍历一遍找最大权值的点会(x)不会(x)太浪Ҏ(gu)_(d)如果用堆取出权值最大的Ҏ(gu)率就?x)有很大改进Q变成n*log(n)?br>但是最大权值的父亲节点也要从堆中取出,q有炚w?br>l合昨天ZOJ月赛比赛中自创的可以取出L节点的二叉堆Q记录位子来实现Q想CҎ(gu)Q多方试验之后果然成功了
在PKU提交也只用了16MS...哈哈
贴出来晒?
#include "stdio.h"
#include 
"string"
#define maxn 1001
//-----------------------Binary Heap------------------------------------
struct Heap {
    
int val,cost,time,idx;
}hh[maxn];
int pos[maxn];
int len;
bool Prior(Heap a,Heap b) {
    
return a.val * b.time > b.val * a.time;
}
void Push(Heap s) {
    
int i;
    
for(i = ++len ; i > 1 && Prior(s,hh[i/2]); i /= 2) {
        hh[i] 
= hh[i/2];
        pos[hh[i].idx] 
= i;
    }
    hh[i] 
= s;
    pos[hh[i].idx] 
= i;
}
Heap Pop(
int idx) {
    
if(idx == -1)    return hh[0];
    Heap ret 
= hh[idx];
    Heap last 
= hh[len--];
    
int i,s;
    
for(i = idx ; i * 2 <= len; i = s) {
        s 
= i * 2;
        
if(s + 1 <= len && Prior(hh[s+1],hh[s])) {
            s 
++;
        }
        
if(Prior(hh[s],last)) {
            hh[i] 
= hh[s];
            pos[hh[i].idx] 
= i;
        } 
else {
            
break;
        }
    }
    hh[i] 
= last;
    pos[hh[i].idx] 
= i;
    
for(i = idx ; i > 1 && Prior(hh[i],hh[i/2]); i /= 2) {
        Heap buf 
= hh[i];
        hh[i] 
= hh[i/2];
        hh[i
/2= buf;
        pos[hh[i].idx] 
= i;
        pos[hh[i
/2].idx] = i/2;
    }
    
return ret;
}
//---------------------------------------------------------------
int father[maxn];
int main() {
    
int n,r,i;
    hh[
0].cost = hh[0].time = hh[0].val = 0;
    
while(scanf("%d%d",&n,&r),n+r) {
        len 
= 0;
        Heap root;
        
for(i =1 ; i <= n ; i ++) {
            Heap buf;
            scanf(
"%d",&buf.cost);
            buf.val 
= buf.cost;
            buf.time 
= 1;
            buf.idx 
= i;
            
if(i == r) {
                root 
= buf;
            } 
else {
                Push(buf);
            }
        }
        
for(i = 1 ; i < n ; i ++) {
            
int a,b;
            scanf(
"%d%d",&a,&b);
            father[b] 
= a;
        }
        
while(len) {
            Heap max 
= Pop(1);
            
int f = father[max.idx];
            
if(f == r) {
                root.cost 
+= max.cost + max.val * root.time;
                root.time 
+= max.time;
                root.val 
+= max.val;            
            } 
else {
                Heap fa 
= Pop(pos[f]);
                fa.cost 
+= max.cost + max.val * fa.time;
                fa.time 
+= max.time;
                fa.val 
+= max.val;
                fa.idx 
= f;
                Push(fa);
            }
            pos[max.idx] 
= -1;
        }
        printf(
"%d\n",root.cost);
    }
    
return 0;
}

下边是n^2的算法,跑了200+MS。。简z是z,但效率不?br>
#include "stdio.h"
#include 
"string"
#define maxn 1001
struct H{
    
int val;
    
int cost;
    
int time;
    
void clear() {
        val 
= cost = time = 0;
    }
}hh[maxn];
int father[maxn];
int main() {
    
int n,r,i;
    
while(scanf("%d%d",&n,&r),n+r) {
        
for(i =1 ; i <= n ; i ++) {
            scanf(
"%d",&hh[i].cost);
            hh[i].val 
= hh[i].cost;
            hh[i].time 
= 1;
        }
        
for(i = 1; i < n ; i ++) {
            
int a,b;
            scanf(
"%d%d",&a,&b);
            father[b] 
= a;
        }
        
while(true) {
            
int idx = 0;
            
for(i = 1 ; i <= n ; i ++) {
                
if(i != r && hh[i].time && (idx == 0 || hh[idx].val * hh[i].time < hh[i].val * hh[idx].time)) {
                    idx 
= i;
                }
            }
            
if(idx == 0)    break;
            
int f = father[idx];
            hh[f].cost 
+= hh[idx].cost + hh[idx].val * hh[f].time;
            hh[f].val 
+= hh[idx].val;
            hh[f].time 
+= hh[idx].time;
            hh[idx].clear();
        }
        printf(
"%d\n",hh[r].cost);
    }
    
return 0;
}




]]>
概率题Lhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/19/83367.htmlshǎ?/dc:creator>shǎ?/author>Tue, 19 May 2009 05:48:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/05/19/83367.htmlhttp://www.shnenglu.com/notonlysuccess/comments/83367.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/19/83367.html#Feedback10http://www.shnenglu.com/notonlysuccess/comments/commentRss/83367.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/83367.html今天lcy老师推荐我看了zjut一位大牛的文章
http://bbs.zjut.com/viewthread.php?tid=1170233&extra=page%3D1
l于略知一二了Q找几道概率题做?br>

http://acm.hdu.edu.cn/search.php?field=problem&key=2262
E(now) = QE(NEXT1) + E(NEXT2) +...+E(NEXTn))/n + 1
每个盔R点徏方程Q注意v点可以走到得Ҏ(gu)能徏方程Q不然会(x)D无解
先floodfill扑ֈL(fng)可以走到得点Q然后徏方程Q最后仍个高斯消元模板解把答案解出来

http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1423
同上一道一怸L(fng)?br>
http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1317
q个需要构造,盔R位子数的转换
惛_盔RnQ都向内飞的话n-2Q都惛_飞n+2Q一个向左一个向右的话就保持n不变Q所以有下列方程
E[n] = E[n+2]/4 + E[n-2]/4 + E[n]/2 + 1

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2619
此题极度郁闷Q{ULE已l推出来了,却因为精度问题过不了
W四个sample我试了三个模板,出来的答案都不一栗。。。?br>用java可过
http://acm.hdu.edu.cn/showproblem.php?pid=3058
上体升版,变成了多串匹配,建Tire囄基础上进行{U?br>一样存在精度问题,用java可过

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2837
因ؓ(f)甉|有上有下Q我索性就把楼的高度加?nbsp; n = n * 2 - 2
那sample来说Q?~10是向上的Q?0~20是向下的Q?0是0Q向上的话又变成1开?br>在第7和第13层会(x)到?我从0层开始,所以每个量都要-1)
q样可以得到{ULE?br>E[i] = E[(i+j)%n]/6 + 1
        for(i =0; i < n ; i ++) {
            
if(i == m ||  i == n-m) {
                mat[i][i] 
= 1;
            } 
else {
                mat[i][i] 
= 6;
                mat[i][n] 
= 6;
                
for(j = 1; j <= 6; j ++) {
                    mat[i][(i
+j)%n] --;
                }
            }
        }
http://acm.hdu.edu.cn/showproblem.php?pid=1204
q题很早开始想了,现在才会(x)做,公式如下Q?br>a = p * (1 - q);
b = q * (1 - p);
E[n] = E[n-1] * a + E[n+1] * b + E[n] * (1 - a - b);
E[0] = 0;
E[N+M] = 1;


q两道AC的代码都短Q应该是公式题。。没上边几道那么有意思。。?br>http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2949
http://acm.pku.edu.cn/JudgeOnline/problem?id=3682


献上W一ơ写的高斯消元模?br>若返回时false则无?br>
/**************************************************
 *    mat里徏好方E?增广矩阵    n*(n+1)
 *    传入方程个数
 *    {案保存在mat[i][i]?br>*************************************************
*/
#include 
"stdio.h"
#include 
"string"
#define ab(a) (((a)>0)?(a):(-a))
#define maxn 100
#define eps 1e-10
double mat[maxn][maxn];
void swap(double &a,double &b) {double t = a;a = b;b = t;}
bool Gauss(int n) {
    
int i,j,row,idx;
    
double maxx,buf;
    
for(row = 0; row < n ; row ++) {
        
for(maxx = 0,i =row ; i < n ; i ++)
            
if(ab(mat[i][row]) > maxx)
                maxx 
= ab(mat[i][row]),idx = i;
        
if(maxx < eps)return false;
        
if(idx != row)    
            
for(j =0 ; j <= n ; j ++)
                swap(mat[row][j],mat[idx][j]);
        
for(i = row + 1; i < n ; i ++)
            
for(buf=mat[i][row]/mat[row][row],j = row; j <= n ; j ++)
                mat[i][j] 
-= buf * mat[row][j];
    }
    
for(i = n-1;i >= 0; i --) {
        
for(j = i +1; j < n ; j ++)
            mat[i][n] 
-= mat[i][j]*mat[j][j];
        mat[i][i] 
= mat[i][n]/mat[i][i];
    }
    
return true;
}



]]>
通。。。?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/05/17/83205.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Sun, 17 May 2009 12:36:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/05/17/83205.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/83205.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/05/17/83205.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/83205.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/83205.html</trackback:ping><description><![CDATA[很好玩的法<br>?~点可以把一块点看成一个点Q大大加快算法。还有一些无法解决的问题也可以用q个来解?br>前几天在林学院做题的时候胡搞搞出来了,哈哈<br>今天又A了一?br>最q对囑֯?wi)越来越有感觉?br><br>http://acm.hdu.edu.cn/showproblem.php?pid=2767<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include </span><span style="color: #000000;">"</span><span style="color: #000000;">stdio.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include </span><span style="color: #000000;">"</span><span style="color: #000000;">algorithm</span><span style="color: #000000;">"</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;"> </span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> std;<br></span><span style="color: #0000ff;">#define</span><span style="color: #000000;"> maxn 20001</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> Node {<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> to;<br>    Node </span><span style="color: #000000;">*</span><span style="color: #000000;"> next;<br>}list[maxn],opp[maxn];<br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> SCC{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> time;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> newid;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> idx;<br>}hh[maxn];<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> time,newid;<br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> flag;<br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> hash[maxn];<br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> hashid[maxn];<br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> gashid[maxn];<br></span><span style="color: #008000;">//</span><span style="color: #008000;">--------------------------------------------</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> dfs(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> idx) {<br>    Node </span><span style="color: #000000;">*</span><span style="color: #000000;"> buf;<br>    buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> list[idx].next;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(buf) {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to]) {<br>            hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>            dfs(buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to);<br>        }<br>        buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> buf</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br>    }<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(time </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #000000;">7</span><span style="color: #000000;">)<br>        time </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">7</span><span style="color: #000000;">;<br>    hh[idx].time </span><span style="color: #000000;">=</span><span style="color: #000000;"> time </span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    hh[idx].idx </span><span style="color: #000000;">=</span><span style="color: #000000;"> idx;<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> dfs2(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> idx) {<br>    Node </span><span style="color: #000000;">*</span><span style="color: #000000;"> buf;<br>    buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> opp[idx].next;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(buf) {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to]) {<br>            hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>            dfs2(buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to);<br>        }<br>        buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> buf</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br>    }<br>    hh[idx].newid </span><span style="color: #000000;">=</span><span style="color: #000000;"> newid;<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> dfs3(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> idx) {<br>    Node </span><span style="color: #000000;">*</span><span style="color: #000000;"> buf;<br>    buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> list[idx].next;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(buf) {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(hh[idx].newid </span><span style="color: #000000;">!=</span><span style="color: #000000;"> hh[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to].newid) {<br>            hashid[hh[idx].newid] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>            gashid[hh[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to].newid] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to]) {<br>            hash[buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>            dfs3(buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to);<br>        }<br>        buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> buf</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br>    }<br>}<br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> cmp(SCC a,SCC b) {<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> a.time </span><span style="color: #000000;">></span><span style="color: #000000;"> b.time;<br>}<br></span><span style="color: #008000;">//</span><span style="color: #008000;">-----------------------------------------</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main() {<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> n,i,a,b,m,T;<br>    Node </span><span style="color: #000000;">*</span><span style="color: #000000;"> buf;<br>    scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">T);<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(T</span><span style="color: #000000;">--</span><span style="color: #000000;">) {<br>        scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">n,</span><span style="color: #000000;">&</span><span style="color: #000000;">m);<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> ; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> n ; i </span><span style="color: #000000;">++</span><span style="color: #000000;">) {<br>            list[i].next </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br>            opp[i].next </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br>        }<br>        </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(m </span><span style="color: #000000;">--</span><span style="color: #000000;">) {<br>            scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">a,</span><span style="color: #000000;">&</span><span style="color: #000000;">b);<br>            buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Node </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc(</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(Node));        </span><span style="color: #008000;">//</span><span style="color: #008000;">正图</span><span style="color: #008000;"><br></span><span style="color: #000000;">            buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to </span><span style="color: #000000;">=</span><span style="color: #000000;"> b;<br>            buf</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> list[a].next;<br>            list[a].next </span><span style="color: #000000;">=</span><span style="color: #000000;"> buf;<br><br>            buf </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Node </span><span style="color: #000000;">*</span><span style="color: #000000;">)malloc(</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(Node));        </span><span style="color: #008000;">//</span><span style="color: #008000;">反图</span><span style="color: #008000;"><br></span><span style="color: #000000;">            buf</span><span style="color: #000000;">-></span><span style="color: #000000;">to </span><span style="color: #000000;">=</span><span style="color: #000000;"> a;<br>            buf</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> opp[b].next;<br>            opp[b].next </span><span style="color: #000000;">=</span><span style="color: #000000;"> buf;<br>        }<br>        memset(hash,</span><span style="color: #0000ff;">false</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">(n</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>        time </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> ; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> n ; i </span><span style="color: #000000;">++</span><span style="color: #000000;">) {                </span><span style="color: #008000;">//</span><span style="color: #008000;">先确定时间戳</span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[i]) {<br>                hash[i] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>                dfs(i);<br>            }<br>        }<br>        sort(hh</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">,hh</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">+</span><span style="color: #000000;">n,cmp);                        </span><span style="color: #008000;">//</span><span style="color: #008000;">按时间戳排序</span><span style="color: #008000;"><br></span><span style="color: #000000;">        memset(hash,</span><span style="color: #0000ff;">false</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">(n</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>        newid </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> ; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> n ; i </span><span style="color: #000000;">++</span><span style="color: #000000;">) {                </span><span style="color: #008000;">//</span><span style="color: #008000;">把点分成几块</span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[hh[i].idx]) {<br>                hash[hh[i].idx] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>                hh[hh[i].idx].newid </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">++</span><span style="color: #000000;">newid;<br>                dfs2(hh[i].idx);<br>            }<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(newid </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">) {<br>            puts(</span><span style="color: #000000;">"</span><span style="color: #000000;">0</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>            </span><span style="color: #0000ff;">continue</span><span style="color: #000000;">;<br>        }<br>        memset(hash,</span><span style="color: #0000ff;">false</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">(n</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>        memset(hashid,</span><span style="color: #0000ff;">false</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">(newid</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>        memset(gashid,</span><span style="color: #0000ff;">false</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">)</span><span style="color: #000000;">*</span><span style="color: #000000;">(newid</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">));<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;"> ; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> n ; i </span><span style="color: #000000;">++</span><span style="color: #000000;">) {                    </span><span style="color: #008000;">//</span><span style="color: #008000;">扑և块的出度入度</span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hash[i]) {<br>                hash[i] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>                dfs3(i);<br>            }<br>        }<br>        </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> cnt </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> cnt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> newid ; i </span><span style="color: #000000;">++</span><span style="color: #000000;">) {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">hashid[i])<br>                cnt </span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #000000;">!</span><span style="color: #000000;">gashid[i])<br>                cnt1 </span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>        }<br>        printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,cnt</span><span style="color: #000000;">></span><span style="color: #000000;">cnt1</span><span style="color: #000000;">?</span><span style="color: #000000;">cnt:cnt1);<br>    }<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> <br><br> <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/83205.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-05-17 20:36 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/05/17/83205.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>又学了一招,随机化法Q用于比赛时候是在没办法的时候的氓剪枝http://www.shnenglu.com/notonlysuccess/archive/2009/05/15/83026.htmlshǎ?/dc:creator>shǎ?/author>Fri, 15 May 2009 02:01:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/05/15/83026.htmlhttp://www.shnenglu.com/notonlysuccess/comments/83026.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/15/83026.html#Feedback4http://www.shnenglu.com/notonlysuccess/comments/commentRss/83026.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/83026.html


不同时刻提交不限不同的结果。。。。学?fn)了。哈?br>比赛时候是在没有办法的时候又多了一?br>付代?br>
#include "stdio.h"
#include 
"algorithm"
#include 
"time.h"
using namespace std;
int n,hash[25];
int A[25][25];
int res,maxdeep;
void fun() {
    
int sum = 0;
    
int a[25],b[25],la =0,lb =0;
    
for(int i =0 ; i < n ; i ++) {
        
if(hash[i])    a[la++= i;
        
else    b[lb++= i;
    }
    
for(int i = 0; i < la; i ++) {
        
for(int j =0 ; j < lb; j ++) {
            sum 
+= A[a[i]][b[j]];
        }
    }    
    
if(sum > res)    res = sum;
}
void dfs(int deep,int start) {
    
if(deep == maxdeep) {
        fun();
        
return ;
    }
    
for(int i =start; i < n ; i ++) {
        
if(!hash[i]) {
            hash[i] 
^= 1;
            dfs(deep
+1,i+1);
            hash[i] 
^= 1;
        }
    }
}
int main() {
    
int i,j;
    
while(scanf("%d",&n) == 1) {
        
for(i =0 ; i < n ; i ++) {
            
for(j =0 ; j < n ; j ++) {
                scanf(
"%d",&A[i][j]);
            }
        }
        res 
= 0;
        
if(n <= 19) {
            maxdeep 
= n / 2;
            memset(hash,
0,sizeof(hash));
            
while(maxdeep) {
                dfs(
0,0);
                maxdeep 
--;
            }
        } 
else {
            
int cnt = 100000;
            srand(time(NULL));
            memset(hash,
0,sizeof(hash));
            
while(cnt --) {
                hash[rand()
%n] ^= 1;
                fun();
            }
        }
        printf(
"%d.\n",res);
    }
    
return 0;
}



]]>
?wi)ŞDPhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/11/82614.htmlshǎ?/dc:creator>shǎ?/author>Mon, 11 May 2009 12:39:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/05/11/82614.htmlhttp://www.shnenglu.com/notonlysuccess/comments/82614.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/11/82614.html#Feedback4http://www.shnenglu.com/notonlysuccess/comments/commentRss/82614.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/82614.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=2196
向下搜一遍,向上搜一?br>http://acm.hdu.edu.cn/showproblem.php?pid=1561
Ҏ(gu)一个节点进行一ơ背包,好题啊,两个DP?wi)Ş和背包结合?br>http://acm.hdu.edu.cn/showproblem.php?pid=1011
q道是当q省赛的压u题,但是感觉和上一道差不多Q一L(fng)隑ֺQ唯一不同的就是这个是无向?我由于思维惯性拿来当单向图作Q纠l了好久。。?
?wi)?背包+临街?br>
下边是从天(dng)I间里找出来的练?br> http://acm.pku.edu.cn/JudgeOnline/problem?id=3345
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3201
http://acm.pku.edu.cn/JudgeOnline/problem?id=3107
http://acm.pku.edu.cn/JudgeOnline/problem?id=1655
http://acm.pku.edu.cn/JudgeOnline/problem?id=2378
http://acm.pku.edu.cn/JudgeOnline/problem?id=3140
http://acm.hdu.edu.cn/showproblem.php?pid=2242
http://acm.timus.ru/problem.aspx?space=1&num=1018
http://acm.pku.edu.cn/JudgeOnline/problem?id=1947
http://acm.pku.edu.cn/JudgeOnline/problem?id=2057
http://acm.pku.edu.cn/JudgeOnline/problem?id=2486
http://acm.pku.edu.cn/JudgeOnline/problem?id=1848
http://acm.pku.edu.cn/JudgeOnline/problem?id=2152



http://acm.hdu.edu.cn/showproblem.php?pid=1520
(W一个树(wi)形DPQ附代码)
最最单的?wi)ŞDP
q学?fn)了父子兄弟l构Q爽

#include "stdio.h"

struct Tree{
    
int father;
    
int child;
    
int brother;
    
int TakeParty;
    
int Not;
    
int Max() {
        
return TakeParty > Not ? TakeParty : Not;
    }
    
void init() {
        father 
= child = brother = Not = 0;
    }
}tree[
6001];

void dfs(int idx ) {
    
int child;
    child 
= tree[idx].child;
    
while(child) {
        dfs(child);
        tree[idx].TakeParty 
+= tree[child].Not;
        tree[idx].Not 
+= tree[child].Max();
        child 
= tree[child].brother;
    }
}

int main() {
    
int n,i,a,b;
    
while(scanf("%d",&n) == 1) {
        
for(i =1 ; i <= n ; i ++) {
            scanf(
"%d",&tree[i].TakeParty);
            tree[i].init();
        }
        
while(scanf("%d%d",&a,&b),a+b) {
            tree[a].father 
= b;
            tree[a].brother 
= tree[b].child;
            tree[b].child 
= a;
        }
        
for(i = 1 ; i <= n ; i ++) {
            
if(!tree[i].father) {
                dfs(i);
                printf(
"%d\n",tree[i].Max());
                
break;
            }
        }
    }
    
return 0;
}



]]>
׃一天时间写的一个很挫很挫的大数模板http://www.shnenglu.com/notonlysuccess/archive/2009/05/06/82079.htmlshǎ?/dc:creator>shǎ?/author>Wed, 06 May 2009 10:37:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/05/06/82079.htmlhttp://www.shnenglu.com/notonlysuccess/comments/82079.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/06/82079.html#Feedback2http://www.shnenglu.com/notonlysuccess/comments/commentRss/82079.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/82079.html#include "iostream"#include "stdio.h"#define Mod 10000using namespace&nbs...  阅读全文

]]>
江省历q省赛题+解析http://www.shnenglu.com/notonlysuccess/archive/2009/05/02/81723.htmlshǎ?/dc:creator>shǎ?/author>Sat, 02 May 2009 13:10:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/05/02/81723.htmlhttp://www.shnenglu.com/notonlysuccess/comments/81723.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/05/02/81723.html#Feedback0http://www.shnenglu.com/notonlysuccess/comments/commentRss/81723.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/81723.htmlhttp://acm.zju.edu.cn/onlinejudge/searchProblem.do?contestId=1&titlefrom=0&authorfrom=0&sourcefrom=0&query=provinc
?x)对每一道做q的题做一个简单的分析Q如果有出错或者不理解可以于我交流

2104 Let the Balloon Rise Zhejiang Provincial Programming Contest 2004
数据很小Q遍历一下,扑ֈ?+Q没有的话就新?br>2105 Number Sequence Zhejiang Provincial Programming Contest 2004
扑@环节Q开hash[7][7]来找Qhash前一个和后一?br>2106 Tick and Tick Zhejiang Provincial Programming Contest 2004
当年应该是金牌题吧,旉是连l的Q不能一U一U分开来计?br>我是Ҏ(gu)题目联立三个不等式方E,然后解出交集
2107 Quoit Design Zhejiang Provincial Programming Contest 2004
最q点对,二分的思想Q据说数据结构书上就有。。?br>2108 Elevator Zhejiang Provincial Programming Contest 2004
单模拟题Q求Z升和下降的层?br>2109 FatMouse' Trade Zhejiang Provincial Programming Contest 2004
按性h(hun)比排序后贪心
2110 Tempter of the Bone Zhejiang Provincial Programming Contest 2004
深搜Q加个奇偶性剪?br>2111 Starship Troopers Zhejiang Provincial Programming Contest 2004
题Q不?x)。。。据说是?wi)ŞDP
5.13补充Q当时看着是的做也不敢做的题Q前几天学习(fn)了熟(zhn)树(wi)形DP后练?fn)了几道题目再来做这题发C炚w不难
?wi)?背包+临街表徏囑֏以轻松A掉此?br>

2474 World Goes Round Zhejiang Provincial Programming Contest 2005
q题数据量好大,n=10Q记得在北师大比赛的时候做q一?*3的八数码也是q样转动规则Q当时是预处理直接秒掉的
q道状态太大,变n为神题了Q不?br>
不是求最优解Q所以我猜测应该是构造出一U方法让它{到目标状?br>//我想是不是可以降l_(d)拼好最左边和最上边可以降一l了。?br>至于怎么构造没有想出来。。。?br>未做出
2475 Benny's Compiler Zhejiang Provincial Programming Contest 2005
判断有向图成环,用拓扑排序,错了N遍,我都怀疑是不是我的拓扑写错了。?br>后来试了一下原来有恶心数据QAi == Bi的时候这L(fng)数据不要计算Q不然就自己成环了?br>2476 Total Amount Zhejiang Provincial Programming Contest 2005
模拟一下,都不用大数加法,直接用long long够了,输出的时候分D输?br>2477 Magic Cube Zhejiang Provincial Programming Contest 2005
题目说不过5步,可以用P代加深搜索,其实题目意思很直白Q就是这道题目很难模拟?br>把魔方的转模拟出来这题目也就做出来了。?br>我把每一U{都计出来写q表里,然后按照q个表{O(jin)K?br>2478 Encoding Zhejiang Provincial Programming Contest 2005
遍历一遍比较当前字W和前一个字W就?br>2479 Cover the Rectangular Ground Zhejiang Provincial Programming Contest 2005
从最左下角的点开始dfsQ每ơ先判断能不能放上,然后扑և当前最左下角的点再dfs
q样很暴力。。最坏的情况不来,大概?0!ơ。。。我晕,一直TLE
后来我试了下数据Q倒是是我的程序真的效率很低,q是只有一些数据都跑不?br>l过多次WA和TLE的测试发现只要有解得数据我都能跑出来Q无解的q接搜到死?br>于是我定义如果深搜次数超q?00000q接蟩出,无解
l果AC了。。。。效率还很高Q由于内存原因拍在第?br>唉,比赛的时候如果能q样AC的话太RP了。。?br>。。求正解。?br>2480 Simplest Task in Windows Zhejiang Provincial Programming Contest 2005
数据量小Q直接水掉,从后往前比较for(i = n- 1; i >= 0 ; i --)Q找到符合的跛_Q最后输Z?br>2481 Unique Ascending Array Zhejiang Provincial Programming Contest 2005
排序后输?br>

2736 Daffodil number Zhejiang Provincial Programming Contest 2006, Preliminary
水题
2737 Occurrence Zhejiang Provincial Programming Contest 2006, Preliminary
题目看清楚后暴力比较久可?br>2738 The Kth BST Zhejiang Provincial Programming Contest 2006, Preliminary
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊?br>推了一个下午啊。。。。。竟然WA。。。。。极度郁闗。。。?br>
吃饭回来l于AC了。。。。再郁闷Q原来是我对BST的理解有误,后来U哥U正了,p样陷入了误区N久。。。。不值得啊。。?br>2739 Color Quantization Zhejiang Provincial Programming Contest 2006, Preliminary
未做出
2740 Message System Zhejiang Provincial Programming Contest 2006, Preliminary
用ƈ查集做,判断是树(wi)q是林q是?br>

2741 Offside Zhejiang Provincial Programming Contest 2006, Preliminary
很脑D的模拟题,我却脑残的错了N~。。。。?br>2742 Toy Bricks Zhejiang Provincial Programming Contest 2006
未做出
2743 Bubble Shooter Zhejiang Provincial Programming Contest 2006
先foldfill一下,把连h的hash掉,然后从最上边每个点开始foldfillQ看q有几个留下
2744 Palindromes Zhejiang Provincial Programming Contest 2006
从回文串的性质上找规律Q每个点向左叛_g长数回文串个?br>2745 01-K Code Zhejiang Provincial Programming Contest 2006
恶心的推推题Q我的方法一定不是最单的Q我开了四l数l还转移状?br>分别存的是:(x)
dp[0?相差几位Q最高到达过Q最低到达过Qn]
q是很烂的方法,我想了很久才惛_来,实在想不出更好的?br>2746 Rank the Teams Zhejiang Provincial Programming Contest 2006
未做出
2747 Paint the Wall Zhejiang Provincial Programming Contest 2006
L?hash卛_Q有Ҏ(gu)力,正解是线D|(wi)
2748 Free Kick Zhejiang Provincial Programming Contest 2006
恶心的集合题Q开始没有看到straight "WALL"构造出一U最优解Q结果WA?br>改了之后也一直WAQ错了无数次后修改了下求夹角的方法,本来有atanQ改成acos竟然AC了~~
思\Q?br>先求出没有wall时候的夹角Q然后减d门员的范_(d)再根据剩下的角度来求Zh?br>2749 Polarium Zhejiang Provincial Programming Contest 2006
很好玩的一道题目,有h竟然能TLE 1000+ơ,而且q箋了半q。。Orz一?br>我跑的比较暴力,效率Z?br>思\Q?br>首先枚D最后的{案Q即每行的黑白情?br>然后Ҏ(gu)q个{案重新d一张地图,每个能走的点(除了边界?都只能走且只Cơ,然后q行DFS
走到l点的时候判断下是否W合条gAC?开始的时候我先判断走完点再判断最后一Ҏ(gu)否是l点Q结果超时了)
2750 Idiomatic Phrases Game Zhejiang Provincial Programming Contest 2006
构造出最短\Q每个串的最?个和最?个就是v点和l点Q?^16个点Q?000条\
我用L??bfs加速优?0ms



2849 Attack of Panda Virus Zhejiang Provincial Programming Contest 2007
按level最和type最的优先队列BFS一?br>2850 Beautiful Meadow Zhejiang Provincial Programming Contest 2007
水题
2851 Code Formatter Zhejiang Provincial Programming Contest 2007
注意出现在后边的'\t'
2852 Deck of Cards Zhejiang Provincial Programming Contest 2007
DP,三维(每组牌的价?加滚动数l能LAC
2853 Evolution Zhejiang Provincial Programming Contest 2007
矩阵题,有点卡时?br>我的l构体模?00*200开不下Q于是我升了我的模板,换了一个全局矩阵
题目意思理解对套个矩阵模板pq了
2854 Fish and Her Bowl Zhejiang Provincial Programming Contest 2007
未做出
2855 Google Map Zhejiang Provincial Programming Contest 2007
用所l公?递归解决
2856 Happy Life Zhejiang Provincial Programming Contest 2007
无论什么状态都一定能构造出可行解的Q所以只要while(1)把和于0的那行变换符P一直都满条g
2857 Image Transformation Zhejiang Provincial Programming Contest 2007
水题



2965 Accurately Say "CocaCola"! The 5th Zhejiang Provincial Collegiate Programming Contest
数据,暴力下就好,数据大的话可以数学归Ux者暴力看下规?a >
2966
Build The Electric System The 5th Zhejiang Provincial Collegiate Programming Contest
d的最树(wi)
2967 Colorful Rainbows The 5th Zhejiang Provincial Collegiate Programming Contest
正解说是半^面交
我是用一个栈Q先按b从大到小排序Q如果然后遍历一下,能出现的放q栈里,能把前面的覆盖掉把栈里的线D|?br>正半_(d)负半轴做两次Q再处理一下小l节好?br>2968 Difference Game The 5th Zhejiang Provincial Collegiate Programming Contest
我先把A数组和B数组的数全部保存C数组里,然后排序
再遍历C数组,i = 0 to n*2
i左边的ؓ(f)B,双的ؓ(f)AQ然后算出到达这个状态A到B的个数AB和BA
Ҏ(gu)q两个数出最的pQX =  Min(AB,BA)QY = |AB - BA|QCi = X * Y* (Y - 1)Q?br>如果比c的话旧更新一下res
如果最后一ơ都没更新到得话是最后的{案一定是负的
所以A和B排序下根据c贪心得到{案
2969 Easy Task The 5th Zhejiang Provincial Collegiate Programming Contest
easy task
2970
Faster, Higher, Stronger The 5th Zhejiang Provincial Collegiate Programming Contest
sort
2971 Give Me the Number The 5th Zhejiang Provincial Collegiate Programming Contest
模拟?a >
2972
Hurdles of 110m The 5th Zhejiang Provincial Collegiate Programming Contest
按剩下的能量DP
2973
Intelligent Pouring Robot The 5th Zhejiang Provincial Collegiate Programming Contest
烦(ch)的模拟题
未做出
2974 Just Pour the Water The 5th Zhejiang Provincial Collegiate Programming Contest
暴力加@环节能过Q正解是矩阵Q?br>K == 0的时候常怼(x)被忽略,处理一下就?br>
2975 Kinds of Fuwas The 5th Zhejiang Provincial Collegiate Programming Contest
n^3的算法,枚DL两行C(2,n)Q遍历列nQ找到相同的个数xQres+=(x-1)*x/2;
2976 Light Bulbs The 5th Zhejiang Provincial Collegiate Programming Contest
枚Dq面上每一个点取最大?br>

3202 Second-price Auction The 6th Zhejiang Provincial Collegiate Programming Contest
3203 Light Bulb The 6th Zhejiang Provincial Collegiate Programming Contest
3204 Connect them The 6th Zhejiang Provincial Collegiate Programming Contest
3205 Derivative The 6th Zhejiang Provincial Collegiate Programming Contest
3206 Disaster Area Reconstruction The 6th Zhejiang Provincial Collegiate Programming Contest
3207
80ers' Memory The 6th Zhejiang Provincial Collegiate Programming Contest
3208
Reforestation The 6th Zhejiang Provincial Collegiate Programming Contest
3209
Treasure Map The 6th Zhejiang Provincial Collegiate Programming Contest
3210 A Stack or A Queue? The 6th Zhejiang Provincial Collegiate Programming Contest
3211 Dream City The 6th Zhejiang Provincial Collegiate Programming Contest
3212 K-Nice The 6th Zhejiang Provincial Collegiate Programming Contest


]]>
二分囄完美匚whttp://www.shnenglu.com/notonlysuccess/archive/2009/04/21/80606.htmlshǎ?/dc:creator>shǎ?/author>Tue, 21 Apr 2009 06:32:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/04/21/80606.htmlhttp://www.shnenglu.com/notonlysuccess/comments/80606.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/04/21/80606.html#Feedback2http://www.shnenglu.com/notonlysuccess/comments/commentRss/80606.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/80606.html学的比较挫,写的是n^4的算?br>实际上有m*m*n的算法的
下边几道是完匹配的题目
http://info.zjfc.edu.cn/acm/problemDetail.aspx?pid=1222 赤裸裸的完美匚wQ图都徏好了
http://acm.hdu.edu.cn/showproblem.php?pid=1533 q个建图很容?br>http://acm.hdu.edu.cn/showproblem.php?pid=2282 q个需要徏?br>
下边是http://acm.hdu.edu.cn/showproblem.php?pid=1533 的AC代码
//////////////////////////////////////////////////////////////////////////
//二分囄完美匚wQKuhnQMunkras法
#include<stdio.h>
#include
<math.h>
#include
<string>
#define MAXN 101
//////////////////////////////////////////////////////////////////////////
#define inf 0x7FFFFFFF
int edge[MAXN][MAXN];
int match[MAXN];
bool hash[MAXN][MAXN];
bool xhash[MAXN],yhash[MAXN];
char map[MAXN][MAXN];
int min(int a,int b){return a>b?b:a;}
int max(int a,int b){return a>b?a:b;}
void Scanf(int n,int m,int &l);
bool dfs(int p,int n)//扑֢q\?/span>
{
    
int i;
    
for(i=0;i<n;i++)
    {
        
if(!yhash[i] && hash[p][i])
        {
            yhash[i] 
= true;
            
int t = match[i];
            
if(t == -1 || dfs(t,n))
            {
                match[i] 
= p;
                
return true;
            }
            
if(t != -1)
                xhash[t] 
= true;
        }
    }
    
return false;
}
void show(int id,int n)
{
    
int i,j;
    
for(i=0;i<n;i++)
    {
        
for(j=0;j<n;j++)
        {
            
if(id)
                printf(
"%d ",edge[i][j]);
            
else
                printf(
"%d ",hash[i][j]);
        }
        puts(
"");
    }
    puts(
"");
}
void KM_Perfect_Match(int n)
{
    
int i,j;
    
int xl[MAXN],yl[MAXN];
    
for(i=0;i<n;i++)
    {
        xl[i] 
= 0;
        yl[i] 
= 0;
        
for(j=0;j<n;j++)
            xl[i] 
= max(xl[i],edge[i][j]);
    }
    
bool perfect = false;
    
while(!perfect)
    {
        
for(i=0;i<n;i++)//现阶D已l匹配的?/span>
        {
            
for(j=0;j<n;j++)
            {
                
if(xl[i] + yl[j] == edge[i][j])
                    hash[i][j] 
= true;
                
else
                    hash[i][j] 
= false;
            }
        }

//        show(0,n);
        int cnt = 0;
        memset(match,
-1,sizeof(match));
        
for(i=0;i<n;i++)//当前的图是否能全部匹?/span>
        {
            memset(xhash,
false,sizeof(xhash));
            memset(yhash,
false,sizeof(yhash));
            
if(dfs(i,n))
                cnt 
++;
            
else
            {
                xhash[i] 
= true;
                
break;
            }
        }
        
if(cnt == n)//没有增广路径
            perfect = true;
        
else
        {
            
int ex = inf;
            
for(i=0;i<n;i++)
            {
                
for(j=0;xhash[i] && j<n;j++)
                {
                    
if(!yhash[j])
                        ex 
= min(ex,xl[i] + yl[j] - edge[i][j]);//扑ֈ一条没建的边的最?/span>
                }
            }
            
for(i=0;i<n;i++)//Ҏ(gu)q个Ҏ(gu)q行村ּ
            {
                
if(xhash[i])
                    xl[i] 
-= ex;
                
if(yhash[i])
                    yl[i] 
+= ex;
            }
        }
    }
}
int main()
{
    
int n,m,l;
    
while(scanf("%d%d",&n,&m))
    {
        
if(n == 0 && m == 0)
            
break;
        Scanf(n,m,l);
        KM_Perfect_Match(l);
        
int mindis = 0;
        
for(int i=0;i<l;i++)
            mindis 
+= edge[match[i]][i];
        printf(
"%d\n",-mindis);
    }
    
return 0;
}

//d建图
void Scanf(int n,int m,int &l)
{
    
int i,j,l1,l2;
    
struct Point{
        
int x,y;
    }MAN[MAXN],HOUSE[MAXN];
    l1 
= l2 = 0;
    
for(i=0;i<n;i++)
    {
        scanf(
"%s",map[i]);
        
for(j=0;j<m;j++)
        {
            
if(map[i][j]=='m')
            {
                MAN[l1].x 
= i;
                MAN[l1].y 
= j;
                l1 
++;
            }
            
else if(map[i][j]=='H')
            {
                HOUSE[l2].x 
= i;
                HOUSE[l2].y 
= j;
                l2 
++;
            }
        }
    }
    l 
= l1;
    
for(i=0;i<l;i++)
        
for(j=0;j<l;j++)
            edge[i][j] 
= -abs(MAN[i].x - HOUSE[j].x) - abs(MAN[i].y - HOUSE[j].y);
}



]]>
又学了一招,矩阵的比?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/04/20/80545.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Mon, 20 Apr 2009 07:47:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/04/20/80545.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/80545.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/04/20/80545.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/80545.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/80545.html</trackback:ping><description><![CDATA[     摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2807昨天比赛q道题目要求矩阵的乘法然后进行比较。。算了一下复杂度是O(n^5)l对时。。比赛的时候一直卡着Q赛后才知道有一U好的算?-矩阵比较法就是二l的矩阵乘以一个一l的矩阵使之降ؓ(f)一l_(d)然后q行比较q样的话只用n^2的算法进行矩늛乘了Q复杂度降成?n^4)利AC、。。?#include<...  <a href='http://www.shnenglu.com/notonlysuccess/archive/2009/04/20/80545.html'>阅读全文</a><img src ="http://www.shnenglu.com/notonlysuccess/aggbug/80545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-04-20 15:47 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/04/20/80545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图论~~要大q一Z--Author McFnhttp://www.shnenglu.com/notonlysuccess/archive/2009/04/17/80222.htmlshǎ?/dc:creator>shǎ?/author>Fri, 17 Apr 2009 03:10:00 GMThttp://www.shnenglu.com/notonlysuccess/archive/2009/04/17/80222.htmlhttp://www.shnenglu.com/notonlysuccess/comments/80222.htmlhttp://www.shnenglu.com/notonlysuccess/archive/2009/04/17/80222.html#Feedback4http://www.shnenglu.com/notonlysuccess/comments/commentRss/80222.htmlhttp://www.shnenglu.com/notonlysuccess/services/trackbacks/80222.html打星L(fng)表示个h认ؓ(f)比较l典Q或是算法,构图比较好的题目

1062* 昂贵的聘C?nbsp;枚D{限制+dijkstra
1087* A Plug for UNIX 2分匹?br>1094 Sorting It All Out floyd ?nbsp;拓扑
1112* Team Them Up! 2分图染色+DP
1125 Stockbroker Grapevine FLOYD
1135 Domino Effect 最短\
1149* PIGS |络?br>1161* Walls floyd
1201 Intervals 差分U束
1236* Network of Schools ?br>1251 Jungle Roads MST
1273 Drainage Ditches 最大流
1274 The Perfect Stall 2分匹?br>1275* Cashier Employment 差分U束
1325 Machine Schedule 2分匹?最点覆盖)
1364 King 差分U束
1422 Air Raid 2分匹?br>1459 Power Network |络?br>1466 Girls and Boys 2分图(最大独立团)
1469 COURSES 2分匹?br>1502 MPI Maelstrom floyd
1511* Invitation Cards 最短\
1637* Sightseeing tour 混合图欧拉回?/span>-|络?br>1716 Integer Intervals 差分U束
1724* ROADS 最短\-拆点
1780* Code Ƨ拉回\
1789 Truck History 最生成树(wi)
1797 Heavy Transportation 最生成树(wi)
1847 Tram 最短\
1904* King's Quest ?/span>
1949 Chores 最短\
2060 Taxi Cab Scheme 2分匹?br>2075 Tangled in Cables 最生成树(wi)
2112 Optimal Milking |络?br>2125 Destroying The Graph 最割
2135 Farm Tour 费用?br>2139 Six Degrees of Cowvin Bacon floyd
2226 Muddy Fields 2分匹?br>2230 Watchcow Ƨ拉回\
2239 Selecting Courses 2分匹?br>2267* From Dusk till Dawn or: Vladimir the Vampire 最短\
2289 Jamie's Contact Groups |络?/span>
2337 Catenyms Ƨ拉通\
2349 Arctic Network 最生成树(wi)
2369 Genealogical tree 拓扑?br>2387 Til the Cows Come Home 最短\
2391* Ombrophobic Bovines 最大流
2394 Checking an Alibi 最短\
2396* Budget |络?br>2421* Constructing Roads 最生成树(wi)
2446 Chessboard 2分匹?br>2455 Secret Milking Machine |络?br>2457 Part Acquisition 最短\
2472 106 miles to Chicago 最短\
2485 Highways 最生成树(wi)
2516 Minimum Cost 费用?br>2536 Gopher II 2分匹?br>2553* The Bottom of a Graph ?br>2570 Fiber Network floyd
2584 T-Shirt Gumbo |络?br>2594* Treasure Exploration 2分匹?br>2723 Get Luffy Out 2-sat
2724 Purifying Machine 2分匹?br>2728 Desert King 最优比例生成树(wi)
2749* Building roads 2-sat
2762 Going from u to v or from v to u? ?br>2949* Word Rings 差分U束
2983 Is the Information Reliable? 差分U束
2987 Firing 最割(求解正确?/span>??)
3020 Antenna Placement 2分匹?br>3041 Asteroids 2分匹?br>3072* Robot 最短\
3160 Father Christmas flymouse ?br>3164 Command Network 最树(wi)形图
3169 Layout 差分U束
3177 Redundant Paths 双联通分?br>3189 Steady Cow Assignment |络?br>3204 Ikki's Story I - Road Reconstruction 最大流
3207 Ikki's Story IV - Panda's Trick 2分图
3216 Repairing Company 2分匹?br>3228 Gold Transportation |络?br>3255 Roadblocks 最短\
3259 Wormholes 最短\
3268 Silver Cow Party 最短\
3275 Ranking the Cows floyd
3281 Dining 最大流
3308 Paratroopers 最割
3310 Caterpillar
3311 Hie with the Pie floyd
3328 Cliff Climbing 最短\
3343 Against Mammoths 2分匹?br>3352 Road Construction ?br>3439 Server Relocation 最短\
3463 Sightseeing 最短\
3469 Dual Core CPU 最割
3487 The Stable Marriage Problem E_婚姻
3522 Slim Span 最生成树(wi)
3594 Escort of Dr. Who How 最短\
3615 Cow Hurdles 最短\
3623 Wedding 2-sat
3653 Here We Go(relians) Again 最短\
3659* Cell Phone Network 最支配集
3660 Cow Contest 拓扑
3662* Telephone Lines 最短\
3678 Katu Puzzle 2-sat
3683* Priest John's Busiest Day 2-sat求解
3687 Labeling Balls 差分U束 ?nbsp;拓扑
3692 Kindergarten 2分匹?br>3694 Network 无向囄?br>
把上面的作为图论学?fn)的题目?/span>~



]]>
半年AC生(dng)Q仅以此文纪?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/04/16/80162.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Thu, 16 Apr 2009 09:08:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/04/16/80162.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/80162.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/04/16/80162.html#Feedback</comments><slash:comments>19</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/80162.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/80162.html</trackback:ping><description><![CDATA[834064 </td> <td>2008-10-16 10:07:01 </td> <td><font color=red>Accepted </font></td> <td><a ><u><font color=#0000ff>1000</font></u></a> </td> <td>0MS </td> <td>0K </td> <td><a target=_blank><u><font color=#0000ff>105 B</font></u></a> </td> <td>C </td> <td class=fixedsize><a ><u><font color=#0000ff>shǎ?/font></u></a><br><br>d10?6PA了第一道A+B,我的AC生(dng)也正是开始了<br><br>今天??6P正好半年Q提交了三道水题。。。在HDU的AC量达C900.。?br> <table style="BORDER-BOTTOM: #1a5cc8 1px dotted" borderColor=#1a5cc8 cellSpacing=2 width="100%" align=center border=0> <tbody> <tr class=table_text align=middle> <td height=22>5</td> <td><a ><u><font color=#0000ff>shǎ?/font></u></a></td> <td>A New Start~Q?/td> <td><a ><font color=#0000ff><u>900</u></font></a></td> <td><a ><u><font color=#0000ff>1888</font></u></a></td> <td>47.67%</td> </tr> </tbody> </table> <br></td> 本来惛_yifenfei大大一般,在纪忉|辑ֈ1000的AC?br>可惜力不从心Q今日比赛甚多,到在其他OJ上刷题,hdoj上的水题又渐,?ch)事~nQ无法完成半q?000的目标~~只好?00来代替一?...XD<br><br>遥想半年前接触ACM?天天跑机?机房不开门就|吧,q曾l有一晚在|吧通过?W二天集训队的学长们看到我半夜的提交的记录以为我带了W记?N块电(sh)板,后来知道我是在网吧通宵A(ch)C的,更加惊讶Q天涯还曑և了一?a ><u><font color=#800080>shǎ?OrOrOrOrz</font></u></a>的题目。提到Acmer in HDU-ACM team are ambitious, especially shǎ? he can spend time in Internet bar doing problems overnight.哈哈Q笑L了。。这题我特地写了很多优化刷到了第一31MSQ哈哈,别h恐怕很难超了?╯_??br><br>q个学期开始后lcy教练?yu)常常提醒我要花一D|间去d一门算法,从最开始的最生成数Q最短\Q到了树(wi)状数l,字典?wi),L化,q几个星期又有搞定图论的目标Q可以说没有lcy教练的督促我q步没有q么明显Q毕竟不学算法只h题的话是没有提高的。?br><br>接着是q队Q放弃了一切时间ACQ寒假更是没有出ȝq,上个学期都是在自己做题,q个学期都是在PKQPK比做题好玩多了,能和高手切磋Q挑战一些^时不敢做的题目,q气好的话,RP爆发下还能拿到前几的名次炫耀一番。?br>大大小l历q了很多场PKQ集训队内部的单人PK有4场,q有几乎每日都有的校外比赛,真是赛事多发期。。上个星期细一下至做?场比赛吧~~q个比赛密度虽然很高Q但是h也越比越兴奋~~哈哈?^ω^)?br><br>前几个星期和州大学的AedkyCion向老师甌出比赛,我从来都没出q,有点紧张,没想到老师一下就{应了,定在5?L(fng)老菜鸟杯l我们出Q暂?题,每h四题Q到现在我只Z两题半,q进度太慢都有点不好意思了。。。前几天又有州师范大学要求我们出题Q老师把Q务交l了我们Q亦U飞Q周天(dng)Q纪哥和我,哈哈Q我分配C道模拟题和一道搜索题。。。这个的??号前q有5道题目要出。。可有的好忙?br>接下来还有期中考试Q宁波的全国邀(g)误。所以今天晚上我又选择通宵(¯H?#175;Q口_(d)争取把题目赶出来Q还有复?fn)下物理。。话说宁波邀(g)误?4~26P我们的英语和数学考试也在q几天,哈哈Q逃过一劫,。。?br><br>接下来这D忙的时期渡过之后Q?月又可以开始疯狂的AC了~~前些日子做了<a >USACO</a>Q超U好玩,有点像闯x式的。过了一些题后开N度更高的题目和算法给你学?fn)~~昨天刚刚创到W二养I一共有六关Q到后边q很多wf的题都出来了Q超有挑战,我一定要全部d。?br>遇到q个OJ后我曄qL以后能写一个新模式的OJQ其实就是借鉴USACOQ升U打怪模式,哈哈Q打?A完题)得到l验|可以M技能书(法)Q然后开放新题目Q一U一U来Q还有很多附属功能。。。当然这只是初步假想而已。。我现在除了AC什么都不会(x)Q更何谈做个新OJ。。不q既焉择了ACQ必定会(x)攑ּ其他很多东西Q所以我可以说是背水一战,攑ּ其他一门心思ACQ一定要在这斚w拿到一个非常好的成l才对得h的大学四q。。?br><br>队内6轮PK完后l于开始组队选队友了Q由于最后一轮RP爆发Q被我赚了很多分敎ͼ排名一下上升到W二Q本是纪哥选我的变成了我选纪哥,哈哈Q还选了丽姐,她可?a >3.8?/a>后全国闻名的人物哦~~一哥一“?#8221;的组合,虽然我和丽姐第一ơ参加省赛,但是我信心十I跟着曄拿过银牌的纪哥省赛一定是要冲金夺银的~~PKl束的那个晚上周天(dng)q和我谈q~~说有Z(x)希望暑假能组?#183;~啊哈Q我真是兴奋x。。他可是我在队内最希望l队的大牛,q队后就一直钦佩他Q现在竟然有Z(x)能在以后一起ƈ肩作战,一起参加全国赛Q冲击金牌,参加wf~~哈啊哈~\(≧▽?/~Q想中。。)(j)<br><br>期待接下ȝl队PKQ省赛,暑假集训Q全国赛~~~当然Q还有world final Q! <br><br><br><br>AC之旅中的酸甜苦G׃再细说了QL看到很多AC多么多么苦,很多“别h只看到AC所得到的荣耀Q而看不到我们背后训练的艰?#8221;<br>其实不是q样的,臛_我不是这PACҎ(gu)而言不是一U负担,不是一U压力,而是一U娱乐,一U生zL式,已经?fn)惯了实验室的生z,可以除了吃饭睡觉都在实验室,q一切都是快乐的~~^_^当然QAC有成果的话会(x)更加的快乐~~~O(∩_∩)O哈哈~ <br><br>一直奔跑下d~~A Crazy Man <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/80162.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-04-16 17:08 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/04/16/80162.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>飘逸的N皇后问题位运代码,U念USACO创过W一关~~matrix67大牛博客上学?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/04/15/79982.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Wed, 15 Apr 2009 04:24:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/04/15/79982.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/79982.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/04/15/79982.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/79982.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/79982.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br>ID:notonlysuccess<br>LANG:C++<br>TASK:checker<br></span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> cnt;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> ans[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">13</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> jilu[</span><span style="COLOR: #000000">13</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n,maxn;<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> dfs(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> row,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> ld,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rd,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> deep)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,buf,pos;<br>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(deep </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> n)<br>    {<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(cnt</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">)<br>        {<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>                ans[cnt][i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> jilu[i];<br>        }<br>        cnt </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> ;<br>    }<br>    buf </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> row </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> ld </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> rd;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        pos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">i;<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">((buf </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000"> pos) </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> pos)<br>            </span><span style="COLOR: #0000ff">continue</span><span style="COLOR: #000000">;<br>        jilu[deep] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br>        dfs(row</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos,(ld</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos)</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,(rd</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos)</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,deep</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br>    }<br>}<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">checker.in</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">r</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdin);<br>    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">checker.out</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdout);<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,j;<br>    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">n);<br>    cnt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    maxn </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n;<br>    dfs(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cnt;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,ans[i][j]);<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,ans[i][j]);<br>    }<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,cnt);<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}<br></span></div> <br><br><br><br><br><br>哈哈Qhdoj上超大数据量的N皇后也过了。?br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> cnt;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n,maxn;<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> dfs(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> row,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> ld,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rd)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> buf,pos;<br>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(row </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> maxn)<br>    {<br>        cnt </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> ;<br>    }<br>    buf </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> row </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> ld </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> rd;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(pos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;pos </span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000"> maxn;pos </span><span style="COLOR: #000000"><<=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br>    {<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">((buf </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000"> pos) </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> pos)<br>            </span><span style="COLOR: #0000ff">continue</span><span style="COLOR: #000000">;<br>        dfs(row</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos,(ld</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos)</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,(rd</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">pos)</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br>    }<br>}<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,pos;<br>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">n),n)<br>    {<br>        cnt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>        maxn </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n) </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            pos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">i;<br>            dfs(pos,pos</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,pos</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br>        }<br>        cnt </span><span style="COLOR: #000000"><<=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(n</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br>        {<br>            pos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">i;<br>            dfs(pos,pos</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,pos</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br>        }<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,cnt);<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/79982.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-04-15 12:24 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/04/15/79982.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>W四轮PK。。?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79740.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Sun, 12 Apr 2009 16:59:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79740.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/79740.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79740.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/79740.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/79740.html</trackback:ping><description><![CDATA[最后一轮PKQ抱q轻村ց做的心态去比,l果Z意料Q哈?br>q次的题目没有以前那么水Q每道都是要动点脑{的<br><br><a >http://acm.tju.edu.cn/toj/showp3256.html</a><br>q是dfsQ我惊讶别h暴力深搜竟然都能q。。。我?br>要是我来处数据的话暴力深搜一定爆掉。?br>我是用hash[ <span lang=en>landscapes </span>][ (<span lang=en>total length</span>)%k ][ Lth ]来剪?br>q样的话最多也搜?0*50*50个状态。。。很好的设计。。嘿嘿又往自己怸贴金?br><br><a >http://acm.tju.edu.cn/toj/showp3257.html</a><br>不太清楚是什么算法,不过我程序里用的数组名是DP。。。当时下手的时候想写成DP的,l果׃伦不cL了XD<br>不管用什么数l名QDP也好QHH也好Q?span style="COLOR: red">?/span>反正记录下每个字母后边的和该字母相同的字母个?br><span style="COLOR: red">?/span>然后用一个minch变量L一遍字W串Q不断更新minch(看到q个变量名应该知道怎么更新的吧)同时记录下标minch的下标pos<br><span style="COLOR: red">?/span>扫到后边相同字母数是0的时候就比较一下,看minch和这个字母谁?br>{<br>如果(minch?<br>      的话p出minch同时下标跛_C前记录的pos;<br>如果(minch?<br>      的话p个字母,然后l箋?<br>再minch更新为最?br>}<br>不要忘记吧已l输出的字母hash掉哦<br><br><a >http://acm.tju.edu.cn/toj/showp3258.html</a><br>一看就是技巧题目。。看成是环,排序后找C个最大的删除区间掉。。然后看看剩下的所能得到的l对值最?br>注意要分c讨论。。比赛的时候被sample骗掉。。以为就是中间对U的只考虑了一U情况,其实有四U。。。?br>错了好多遍。。。?br><br><a >http://acm.tju.edu.cn/toj/showp3259.html</a><br>单题Q晒法晒下然后再预处理一?br><br><a >http://acm.tju.edu.cn/toj/showp3260.html</a><br>图论ѝ。看到就晕了。。。向来没有做q图论的题,最q也就是二分图的最大匹?br>完全匚w都还没有学过。?br>没办法。。抱着一U希望来个强剪枝试试。。。结果不出所料TLE了。。。?br><br>两个时的时候就Z前四道暂时第一了,<a ><u><font color=#0000ff>Luke King</font></u></a>Z三道Q而我的罚时太多(因ؓ(f)心态比较放松,所有一有思\写好了就提交QW(xu)A了修改一下又提交又WAQ其实很多罚时是不必要的Q。。囧了。所?a ><u><font color=#0000ff>Luke King</font></u></a>只要在比赛前出题p过我。A是比较简单的<br>果然Q在最后十分钟ZA过我了Q我在最后十分钟提交了EQ结果是时。?br><br>赛后得知<a ><u><font color=#0000ff>Luke King</font></u></a>?9的。。。天z市(jng)赛第六。。高中生ѝ。Orz <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/79740.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-04-13 00:59 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79740.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>W三轮PK。。。?/title><link>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79739.html</link><dc:creator>shǎ?/dc:creator><author>shǎ?/author><pubDate>Sun, 12 Apr 2009 16:24:00 GMT</pubDate><guid>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79739.html</guid><wfw:comment>http://www.shnenglu.com/notonlysuccess/comments/79739.html</wfw:comment><comments>http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79739.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/notonlysuccess/comments/commentRss/79739.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/notonlysuccess/services/trackbacks/79739.html</trackback:ping><description><![CDATA[<a >http://acm.tju.edu.cn/toj/showp3251.html</a><br>水题。。。瞬间被人秒的。。drogon大大说算日期和星期的有个什么公式,学习(fn)<br><a >http://acm.tju.edu.cn/toj/showp3252.html</a><br>深搜Q每ơ搜到四个区域的g持一下,然后枚D12U可能取最?br><a >http://acm.tju.edu.cn/toj/showp3253.html</a><br>比赛的时候想了半个小时的矩阵构造。。。后来发?^20一定有循环节。用未压~保存了状态然后hash<br>l果最后半个小时提交的时候电(sh)脑蓝屏(三教的破?sh)脑Q,开原后代码全无<br>启动q启动了10分钟。?zhn)剧收场,人品不好啊。。?br><a >http://acm.tju.edu.cn/toj/showp3254.html</a><br>模拟加贪心。简单题<br><a >http://acm.tju.edu.cn/toj/showp3255.html</a><br>比赛的时候时间都花在了C上边Q没旉看。。?br><br><br>q场比赛只有两道水题Q所有我做了三道也都排在了前?nbsp;  %>_<%   要是?sh)脑不蓝屏。。? <img src ="http://www.shnenglu.com/notonlysuccess/aggbug/79739.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/notonlysuccess/" target="_blank">shǎ?/a> 2009-04-13 00:24 <a href="http://www.shnenglu.com/notonlysuccess/archive/2009/04/13/79739.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.xiaodaoyl.cn" target="_blank">þþþþ</a>| <a href="http://www.nyoh.cn" target="_blank">þþþþþƷþþþ</a>| <a href="http://www.lyfulinmen.com.cn" target="_blank">þ޾ƷƷ</a>| <a href="http://www.txhyhf.cn" target="_blank">þӰ</a>| <a href="http://www.u5qe.cn" target="_blank">պŷۺϾþ</a>| <a href="http://www.366509.cn" target="_blank">þþþ99ƷƬԿ</a>| <a href="http://www.cq81.cn" target="_blank">˾þó˳ۺ222</a>| <a href="http://www.ihi7113575.cn" target="_blank">޾ƷþþӰԺӰƬ </a>| <a href="http://www.benzclub.com.cn" target="_blank">뾫Ʒþһ </a>| <a href="http://www.gjvthsj.cn" target="_blank">þ99Ʒ99þ6</a>| <a href="http://www.xixirt.cn" target="_blank">ɫۺϾþþþĻ </a>| <a href="http://www.ding-u.cn" target="_blank">޹˾þһþ</a>| <a href="http://www.5748l.cn" target="_blank">鶹ŷۺϾþ</a>| <a href="http://www.udyq.cn" target="_blank">ĻӰӾþþѹۿ</a>| <a href="http://www.sdxingying.com.cn" target="_blank">91Ʒ91Ⱦþþþø</a>| <a href="http://www.weijulian.cn" target="_blank">þˬ˸߳AV</a>| <a href="http://www.abovefq.cn" target="_blank">þeֻйľƷ99</a>| <a href="http://www.etnz.cn" target="_blank">99þþþ</a>| <a href="http://www.zhaodongjie.cn" target="_blank">þþƷһ</a>| <a href="http://www.piaowutong.com.cn" target="_blank">ٸþþþþñŪ߳</a>| <a href="http://www.fanqiejidi.cn" target="_blank">˾þվ</a>| <a href="http://www.dgdike.cn" target="_blank">Ʒþþþ</a>| <a href="http://www.etxf.cn" target="_blank">þþþþþþþѾƷ</a>| <a href="http://www.hhh328.cn" target="_blank">þþþþþۺۺϺݺ</a>| <a href="http://www.apple-tree.com.cn" target="_blank">þþþ뾫Ʒapp</a>| <a href="http://www.xldgdq.cn" target="_blank">޳avƬþ</a>| <a href="http://www.norid.cn" target="_blank">2021ھƷþþþþӰԺ</a>| <a href="http://www.it0557.cn" target="_blank">ۺҹҹþ</a>| <a href="http://www.dgdike.cn" target="_blank">޳ɫWWWþվ</a>| <a href="http://www.yzx777.cn" target="_blank">aaaƷþþùƬ</a>| <a href="http://www.txhyhf.cn" target="_blank">þѾDzݲƷ</a>| <a href="http://www.h3cedu.cn" target="_blank">ɫþþۺ</a>| <a href="http://www.shjinhuashiye.cn" target="_blank">޾Ʒþþþþο </a>| <a href="http://www.ssc929.cn" target="_blank">þŮˬŮˬ</a>| <a href="http://www.lsdkgoio8843.cn" target="_blank">ҰAVþһ</a>| <a href="http://www.s360.com.cn" target="_blank">޾Ʒþþþ</a>| <a href="http://www.starlight-caraccessories.cn" target="_blank">þ99þ99Ʒӿ</a>| <a href="http://www.hystech.cn" target="_blank">޹Ʒþþϼ2 </a>| <a href="http://www.zhihuzhuanlan.com.cn" target="_blank">97Ʒ˾þþô߽97 </a>| <a href="http://www.jinxing168.net.cn" target="_blank">.Ʒþþ鶹Ʒ </a>| <a href="http://www.matory.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>