ImageVerifierCode 换一换
格式:DOC , 页数:56 ,大小:302KB ,
资源ID:7016289      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/7016289.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(搜索题目类型各题总结-acm.doc)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

搜索题目类型各题总结-acm.doc

1、一个让人感觉很复杂的BFS(但是并不很复杂) 问题 D: BFS_连连看游戏 时间限制: 2 Sec 内存限制: 5 MB 提交: 12 解决: 3 [提交][状态][讨论版] 题目描述 大 家都玩过连连看吧!今天我们玩一个类似的游戏。在一个由10*10个小方格组成的矩形里有n(n<=10)对字符(它们是大写字符中的前n个)。矩 形里有些位置是可以从上面走过,有些则不能。能走过的位置用'.'标识,不能的用'#'标识。如果2个相同字符是连通的(从一个字符能走到另一个字符,注 意走的时候只能向上、下、左、右走。某个位置是有其他字符时,这个位置是不能走的),那么这对字符能够进行配对。

2、如果将这对字符配对,这对字符将从这个矩 形里消除,也就是说这2个字符所在的位置对于其他字符而言变成能走动了。 现在的问题是:请你决定这些字符的配对顺序(只有能配对才能进行配对),使得n对字符最后都配对成功。 输入 先给出一个正整数t(t<=10),表示有t组测试数据。 每组测试数据有10行组成,每行有10个字符。这些字符只能是'.','#',或者是大写字符中的前n个。每组测试数据中不超过10对字符。 输出 如果能够使每组测试数据中的n对字符配对成功,输出配对的顺序。如果有多种配对成功的顺序,输出字典序最小的那组。 否则输出"My God!"。 样例输入 2 ABF.

3、 CE........ D......... .......... .......... .......... .......... .........D ........EC .......FBA ABF....... CE........ D......... .......... .......... .........# ........#D .........# ........EC .......FBA 样例输出 DCABEF My God! 参考了下老师的代码 其实我一直的思路也都是这样的 而且还动手写了 但是都

4、是写到一半的时候放弃了 因为心里畏惧 害怕超时 还害怕复杂 以后做一个题目的时候要是有一定的把握就不要畏惧 不要婆婆妈妈的 大大方方的把代码敲出来 干掉它 #include #include #include using namespace std; int step[4][2]={-1,0,1,0,0,-1,0,1}; char map[11][11]; int used[11][11]; char ans[20]; struct haha { int x; int y;

5、 int step; friend bool operator <(struct haha a,struct haha b) { return a.step>b.step; } }q,temp; int BFS(int x,int y) { int x1,y1,i; priority_queueque; memset(used,0,sizeof(used)); q.x=x;q.y=y;q.step=0; used[x][y]=1;

6、 que.push(q); while(!que.empty()) { temp=que.top(); que.pop(); for(i=0;i<4;i++) { x1=temp.x+step[i][0]; y1=temp.y+step[i][1]; if(x1>=0&&x1<10&&y1>=0&&y1<10

7、used[x1][y1]&&(map[x1][y1]=='.'||map[x1][y1]==map[x][y])) { if(map[x1][y1]==map[x][y]) { map[x1][y1]='.'; map[x][y]='.';return 1;

8、 } q.x=x1; q.y=y1; q.step=temp.step+1; que.push(q); used[x1][y1]=1; } } }

9、 return 0; } int main() { int cas,k; while(scanf("%d",&cas)!=EOF) { while(cas--) { int i,j,end=0,end2,flag=0,cnt=0; for(i=0;i<10;i++) scanf("%s",map[i]); while(!end) {

10、 for(k='A';k<='M'&&!end;k++)/*借鉴老师的方法感觉比较好 一开始就是怕处理太麻烦不敢下手其实只要试着去做的时候才会发现其实没那么复杂*/ { end2=0; for(i=0;i<10&&!end2;i++) for(j=0;j<10&&!end2;j++)//这个终止方法好漂亮啊

11、省去了一堆break 以前的方法太笨了 { if(map[i][j]==k) { if(BFS(i,j)) {ans[cnt++]=k;end=end2=1;} else end2=1; } }

12、 } if(end==0) break; end=0; } for(i=0;i<10;i++) for(j=0;j<10;j++) { if(map[i][j]!='.'&&map[i][j]!='#') {flag=1;break

13、} } if(flag) printf("My God!\n"); else { for(i=0;i

14、War Accepted : 43 Time Limit : 1000 MS Description 战争即和平,自由即奴役,无知即力量。 ——乔治.奥威尔 历史书上说,自从统治者Big Brother去 世以后,大洋国就陷入了无休止的内战中,随时都可能有新的武装势力出现,随时都可能有战争发生。奇怪的是,每次战争都是在当前国内战斗力最强大的两股势力 间进行,我们可以把每股武装势力的战斗力量化成一个值,每次战争都是在当前战斗力值最高的两股势力间进行。如果有多支势力战斗力值相同,则名字字典序大的 在前(见下面第二组样例)。一场战争结束后,战斗力稍弱的那方被消灭,另一方也元气

15、大伤,战斗力减弱为两支武装的战斗力之差。如果发生战争的两方战斗力相 同,则他们会同归于尽。 历史书上详细记录了该段时期的事件,记录分为两种格式: 1) New name value 其中name和value是变量,表示一个名字叫做name,战斗力为value的新势力出现 2) Fight 表示在当前最强的两股势力间发生了战争 现在请你根据书上记录,计算出每场战争以后分别导致哪支(或哪两支)势力被消灭。 输入 输入的第一行包含一个整数T (T ≤ 15),表示共有T组数据。接下来每组数据的第一行是一个整数N (N ≤ 50000),表示有N条记录。接下来

16、N行,每行表示一条记录,记录的格式如上所述。输入保证每股势力的名字都不相同,势力的名字仅包含小写字母,长度不超过20。战斗力值为不超过10000的正整数。保证当战争发生时至少有两支势力存在。 输出 对每组数据,输出一行“Case X:”作为开头,此处X为从1开始的编号。注意首字母C为大写,在“Case”和编号X之间有一个空格,在编号X后面有一个冒号。然后对每条Fight记录输出一行,表示被消灭的势力的名字。如果是两支势力同归于尽,则这两个名字都应该输出,字典序大的在前,两个名字之间用一个空格隔开。 样例输入 2 5 New obrien 100

17、 New winston 199 Fight New julia 99 Fight 4 New miniluv 100 New minipax 100 New minitrue 100 Fight 样例输出 Case 1: obrien winston julia Case 2: minitrue minipax "开启时代杯"湘潭市第二届大学生程序设计大赛 (Internet) #include #include #incl

18、ude using namespace std; struct haha { char s[50]; int val; bool operator <(const haha &a) const //第一次去尝试 二个判断 以前也没有见过 { if(val!=a.val) return val0) ret

19、urn false; } } }q,temp1,temp2; int main() { int i,j,cas; scanf("%d",&cas); for(i=1;i<=cas;i++) { int n,val; printf("Case %d:\n",i); priority_queueduilie;// char s[30]; scanf("%d",&n);// while(n--) { scanf("%s",s); if(s[0]

20、'N') { scanf("%s %d",q.s,&q.val); duilie.push(q); } else { temp1=duilie.top(); duilie.pop(); temp2=duilie.top(); duilie.pop(); if(temp1.val>temp2.val) { printf("%s\n",temp2.s); temp1.val-=temp2.val; duilie.pus

21、h(temp1); } else if(temp1.val

22、me Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 628 Accepted Submission(s): 173 Problem Description Princess claire_ was jailed in a maze by Grand Demon Monster(GDM) teoy. Out of anger, little Prince ykwd decides to break into the maze t

23、o rescue his lovely Princess. The maze can be described as a matrix of r rows and c columns, with grids, such as 'Y', 'C', '*', '#' and 'P', in it. Every grid is connected with its up, down, left and right grids. There is only one 'Y' which means the initial position when Prince ykwd breaks into t

24、he maze. There is only one 'C' which means the position where Princess claire_ is jailed. There may be many '*'s in the maze, representing the corresponding grid can be passed through with a cost of certain amount of money, as GDM teoy has set a toll station. The grid represented by '#' means tha

25、t you can not pass it. It is said that as GDM teoy likes to pee and shit everywhere, this grid is unfortunately damaged by his ugly behavior. 'P' means it is a transmission port and there may be some in the maze. These ports( if exist) are connected with each other and Prince ykwd can jump from on

26、e of them to another. They say that there used to be some toll stations, but they exploded(surely they didn't exist any more) because of GDM teoy's savage act(pee and shit!), thus some wormholes turned into existence and you know the following things. Remember, Prince ykwd has his mysterious powe

27、r that he can choose his way among the wormholes, even he can choose to ignore the wormholes. Although Prince ykwd deeply loves Princess claire_, he is so mean that he doesn't want to spend too much of his money in the maze. Then he turns up to you, the Great Worker who loves moving bricks, for hel

28、p and he hopes you can calculate the minimum money he needs to take his princess back. Input Multiple cases.(No more than fifty.) The 1st line contains 3 integers, r, c and cost. 'r', 'c' and 'cost' is as described above.(0 < r * c <= 5000 and money is in the range of (0, 10000] ) Then an r *

29、 c character matrix with 'P' no more than 10% of the number of all grids and we promise there will be no toll stations where the prince and princess exist. Output One line with an integer, representing the minimum cost. If Prince ykwd cannot rescue his princess whatever he does, then output "

30、Damn teoy!".(See the sample for details.) SampleInput 1 3 3 Y*C 1 3 2 Y#C 1 5 2 YP#PC SampleOutput 3 Damn teoy! 0 题意: Y开始点 C 终止点 P 传送门 与所有传送门连同 # 墙 *能走的地方 但是要钱 只有*要钱 输入 行数 列数 以及钱 问花的 最少的钱是多少 #include #include #include #include

31、eue> using namespace std; int hang,lie,val,cnt; char map[5100][5100]; struct haha { int x; int y; int val; friend bool operator<(struct haha a,struct haha b) { return a.val>b.val; } }q,temp; struct p { int x; int y; }a[5000+10]; int step[4][2]={1,0,-1,0,0,1,0,-1},s_x,s_y

32、e_x,e_y;//把坐标存成了字符型 艾 一天全是低级错误 脑子不清醒 int BFS() { int i,j,xx,yy,ans=999999999; priority_queueque; q.x=s_x; q.y=s_y;///////// 已开始这里写成了e_y 想打自己啊 q.val=0; que.push(q); map[s_x][s_y]='#'; while(!que.empty()) { temp=que.top(); que.pop(); for(i=0;i<4;i++) {

33、 xx=temp.x+step[i][0]; yy=temp.y+step[i][1]; if(xx>=0&&xx=0&&yytemp.val) ans=temp.val;continue; } if(map[xx][yy]=='*') { map[xx][yy]='#';

34、q.x=xx; q.y=yy; q.val=temp.val+val;//////这里忘记加temp.val MLE了 que.push(q); continue; } if(map[xx][yy]=='P') { for(j=0;j

35、 q.y=a[j].y; q.val=temp.val; que.push(q); map[q.x][q.y]='#'; } } } } } } return ans; } int main() { int i,j,ans; while(scanf("%d %d %d",&hang,&lie,&val)!=EOF) { cnt=0; for(i=0;i

36、 scanf("%s",map[i]); for(j=0;j

37、turn 0; } BFS之打印路径 虐死我得一个题 hdu1026 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6305 Accepted Submission(s): 1882 Special Judge Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius h

38、as to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth. To make the problem simply, we assume the labyrinth is a N*M two-dimensional array which left-top corner is (0,0) and right-bottom corner is (N-1,M-1). Ignatius enters at (0,0), and the door to fen

39、g5166's room is at (N-1,M-1), that is our target. There are some monsters in the castle, if Ignatius meet them, he has to kill them. Here is some rules: 1.Ignatius can only move in four directions(up, down, left, right), one step per second. A step is defined as follow: if current position is (x,

40、y), after a step, Ignatius can only stand on (x-1,y), (x+1,y), (x,y-1) or (x,y+1). 2.The array is marked with some characters and numbers. We define them like this: . : The place where Ignatius can walk on. X : The place is a trap, Ignatius should not walk on it. n : Here is a monster with n HP(

41、1<=n<=9), if Ignatius walk on it, it takes him n seconds to kill the monster. Your task is to give out the path which costs minimum seconds for Ignatius to reach target position. You may assume that the start position and the target position will never be a trap, and there will never be a monster

42、 at the start position. Input The input contains several test cases. Each test case starts with a line contains two numbers N and M(2<=N<=100,2<=M<=100) which indicate the size of the labyrinth. Then a N*M two-dimensional array follows, which describe the whole labyrinth. The input is terminated b

43、y the end of file. More details in the Sample Input. Output For each test case, you should output "God please help our poor hero." if Ignatius can't reach the target position, or you should output "It takes n seconds to reach the target position, let me show you the way."(n is the minimum seconds)

44、 and tell our hero the whole path. Output a line contains "FINISH" after each test case. If there are more than one path, any one is OK in this problem. More details in the Sample Output. 5 6 .XX.1. ..X.2. 2...X. ...XX. XXXXX. 5 6 .XX.1. ..X.2. 2...X. ...XX. XXXXX1 5 6 .XX... ..XX1.

45、 2...X. ...XX. XXXXX. Sample Output It takes 13 seconds to reach the target position, let me show you the way. 1s:(0,0)->(1,0) 2s:(1,0)->(1,1) 3s:(1,1)->(2,1) 4s:(2,1)->(2,2) 5s:(2,2)->(2,3) 6s:(2,3)->(1,3) 7s:(1,3)->(1,4) 8s:FIGHT AT (1,4) 9s:FIGHT AT (1,4) 10s:(1,4)->(1,5)

46、 11s:(1,5)->(2,5) 12s:(2,5)->(3,5) 13s:(3,5)->(4,5) FINISH It takes 14 seconds to reach the target position, let me show you the way. 1s:(0,0)->(1,0) 2s:(1,0)->(1,1) 3s:(1,1)->(2,1) 4s:(2,1)->(2,2) 5s:(2,2)->(2,3) 6s:(2,3)->(1,3) 7s:(1,3)->(1,4) 8s:FIGHT AT (1,4) 9s:FIGHT

47、AT (1,4) 10s:(1,4)->(1,5) 11s:(1,5)->(2,5) 12s:(2,5)->(3,5) 13s:(3,5)->(4,5) 14s:FIGHT AT (4,5) FINISH God please help our poor hero. FINISH 题意:给个二维数组,'.'可以走,'X'不可走,'1-9'代表在此消耗的时间 输出记录从(0,0)到(n-1,m-1)的耗时最小值 #include #include using namespace std; int

48、m,n; char a[105][105]; int d[4][2]={{-1,0},{0,-1},{1,0},{0,1}}; struct haha { int x1; int y1; int ti; friend bool operator < (haha a, haha b) { return a.ti > b.ti; //重载小于号使得小的先出队列 } }q,temp; int flag[105][105]; struct xixi { int x2;

49、 int y2; }pre[105][105]; void BFS() { int i,x,y,time,x0,y0,xi,yi,j,tm; q.x1=n-1;q.y1=m-1;q.ti=0; if(a[n-1][m-1]>=48&&a[n-1][m-1]<=57) q.ti=a[n-1][m-1]-'0'; priority_queueduilie;//这个要放进来 每次都要进行从新分配一个队列 不然的话 就

50、会造成上一次的数据无法清空 duilie.push(q); while(!duilie.empty()) { temp=duilie.top(); duilie.pop(); if(temp.x1==0&&temp.y1==0) { printf ("It takes %d seconds to reach the target position, let me sh

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服