﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-elementlz</title><link>http://www.cppblog.com/elementlz/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 09 Apr 2026 06:28:44 GMT</lastBuildDate><pubDate>Thu, 09 Apr 2026 06:28:44 GMT</pubDate><ttl>60</ttl><item><title>SCTC2010 - 游戏</title><link>http://www.cppblog.com/elementlz/archive/2010/04/15/112657.html</link><dc:creator>EleMenTLz</dc:creator><author>EleMenTLz</author><pubDate>Thu, 15 Apr 2010 05:31:00 GMT</pubDate><guid>http://www.cppblog.com/elementlz/archive/2010/04/15/112657.html</guid><wfw:comment>http://www.cppblog.com/elementlz/comments/112657.html</wfw:comment><comments>http://www.cppblog.com/elementlz/archive/2010/04/15/112657.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/elementlz/comments/commentRss/112657.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/elementlz/services/trackbacks/112657.html</trackback:ping><description><![CDATA[<div><span  style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: small;"><div>lxhgww最近迷上了一款游戏，在游戏里，他拥有很多的装备，每种装备都有2个属性，这些属性的值用[1,10000]之间的数表示。当他使用某种装备时，他只能使用该装备的某一个属性。并且每种装备最多只能使用一次。<br>游戏进行到最后，lxhgww遇到了终极boss，这个终极boss很奇怪，攻击他的装备所使用的属性值必须从1开始连续递增地攻击，才能对boss产生伤害。也就是说一开始的时候，lxhgww只能使用某个属性值为1的装备攻击boss，然后只能使用某个属性值为2的装备攻击boss，然后只能使用某个属性值为3的装备攻击boss&#8230;&#8230;以此类推。<br>现在lxhgww想知道他最多能连续攻击boss多少次？</div><div>对于30%的数据，保证N&lt;=1000</div><div>对于100%的数据，保证N&lt;=1000000</div></span></div><div>#include&lt;iostream&gt;</div><div>#define MAXM 1000001</div><div>#define MAXN 1000001</div><div>#define MAXNANS 10000</div><div>using namespace std;</div><div>int a,b,n,tot,Tnow[MAXM],Ty[MAXM],pre[MAXM];</div><div>int head;</div><div>int from[MAXN];</div><div>bool visit[MAXN];</div><div>int Happen[MAXN];</div><div>bool find(int x){</div><div>&nbsp;&nbsp; &nbsp;int mark = Tnow[x];</div><div>&nbsp;&nbsp; &nbsp;while (mark &gt; 0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!visit[Ty[mark]])</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;visit[Ty[mark]] = true;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Happen[++head] = Ty[mark];</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((!from[Ty[mark]]) || (find(from[Ty[mark]])))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from[Ty[mark]] = x;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return true;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mark = pre[mark];</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;return false;</div><div>&nbsp;&nbsp; &nbsp;}</div><div>void cnt(int x,int y){</div><div>&nbsp;&nbsp; &nbsp; tot++;</div><div>&nbsp;&nbsp; &nbsp; pre[tot] = Tnow[x];</div><div>&nbsp;&nbsp; &nbsp; Tnow[x] = tot;</div><div>&nbsp;&nbsp; &nbsp; Ty[tot] = y;</div><div>}</div><div>int main(){</div><div>&nbsp;&nbsp; &nbsp;freopen("game.in","r",stdin);</div><div>&nbsp;&nbsp; &nbsp;freopen("game.out","w",stdout);</div><div>&nbsp;&nbsp; &nbsp;cin&gt;&gt;n;</div><div>&nbsp;&nbsp; &nbsp;tot = 0;</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=n;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cin&gt;&gt;a&gt;&gt;b;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cnt(a,i+MAXNANS);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cnt(b,i+MAXNANS);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;int Answer ;</div><div>&nbsp;&nbsp; &nbsp;memset(visit,false,sizeof(visit));</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=n;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;head = 0;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!find(i))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Answer = i - 1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int i=1;i&lt;=head;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;visit[Happen[i]] = false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;printf("%d\n",Answer);</div><div>&nbsp;&nbsp; &nbsp;return 0;</div><div>}</div><div><br></div><img src ="http://www.cppblog.com/elementlz/aggbug/112657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/elementlz/" target="_blank">EleMenTLz</a> 2010-04-15 13:31 <a href="http://www.cppblog.com/elementlz/archive/2010/04/15/112657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Candy.</title><link>http://www.cppblog.com/elementlz/archive/2010/04/14/112589.html</link><dc:creator>EleMenTLz</dc:creator><author>EleMenTLz</author><pubDate>Wed, 14 Apr 2010 14:50:00 GMT</pubDate><guid>http://www.cppblog.com/elementlz/archive/2010/04/14/112589.html</guid><wfw:comment>http://www.cppblog.com/elementlz/comments/112589.html</wfw:comment><comments>http://www.cppblog.com/elementlz/archive/2010/04/14/112589.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/elementlz/comments/commentRss/112589.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/elementlz/services/trackbacks/112589.html</trackback:ping><description><![CDATA[<span  style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><div>内部不包含0的最大矩阵和.</div><div>#include&lt;cstdio&gt;</div><div>#include&lt;algorithm&gt;</div><div>#define maxn 1001</div><div>#define maxm 1001</div><div>#define INF 0x7fffffff</div><div>using namespace std;</div><div>int n,m;</div><div>int sum[maxn][maxm];</div><div>int l[maxn][maxn],r[maxn][maxn],h[maxn][maxn],v[maxn][maxn];</div><div>int L[maxn][maxn],R[maxn][maxn];</div><div>int getsum(int a,int b,int c,int d){</div><div>&nbsp;&nbsp; &nbsp;return (sum[c][d]-sum[a-1][d]-sum[c][b-1]+sum[a-1][b-1]);</div><div>&nbsp;&nbsp; &nbsp;}</div><div>int main(){</div><div>&nbsp;&nbsp; &nbsp;freopen("Candy.in","r",stdin);</div><div>&nbsp;&nbsp; &nbsp;freopen("Candy.out","w",stdout);</div><div>&nbsp;&nbsp; &nbsp;scanf("%d%d",&amp;n,&amp;m);</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=n;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for (int j=1;j&lt;=m;j++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf("%d",&amp;v[i][j]);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+v[i][j];</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=n;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int j=1;j&lt;=m;j++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (v[i][j]!=0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;l[i][j] = l[i][j-1]+1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int j=m;j&gt;=1;j--)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (v[i][j]!=0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;r[i][j] = r[i][j+1]+1;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=m;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;h[1][i] = 0;</div><div>&nbsp;&nbsp; &nbsp;memset(L,63,sizeof(L));</div><div>&nbsp;&nbsp; &nbsp;memset(R,63,sizeof(R));</div><div>&nbsp;&nbsp; &nbsp;int Answer = -INF;</div><div>&nbsp;&nbsp; &nbsp;for (int i=1;i&lt;=n;i++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for (int j=1;j&lt;=m;j++)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (v[i][j]!=0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;h[i][j] = h[i-1][j]+1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;L[i][j] = min ( l[i][j] , L[i-1][j]);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;R[i][j] = min ( r[i][j] , R[i-1][j]);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Answer = max ( Answer , getsum (i-h[i][j]+1,j-L[i][j]+1,i,j+R[i][j]-1) );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;printf("%d\n",Answer);</div><div>&nbsp;&nbsp; &nbsp;return 0;</div><div>}</div><div><br></div></span><img src ="http://www.cppblog.com/elementlz/aggbug/112589.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/elementlz/" target="_blank">EleMenTLz</a> 2010-04-14 22:50 <a href="http://www.cppblog.com/elementlz/archive/2010/04/14/112589.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>