This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 其实,这道普及/提高-的题挺简单的,只要四个方格内有三个是‘#’,那么,就直接可以输出‘Bad placement.’了,没有在搜下去的意义了,先判断这个,除去特殊情况后就可以直接搜索船只的数量了。 | |
| #### 本蒟蒻一开始只有72分,检查了半天竟然是搜索起点错了(无语...) | |
| ## 下面直接上代码: | |
| ``` | |
| var | |
| n,m,i,j,sum:longint; | |
| a:array[0..1001,0..1001] of char; | |
| procedure dfs(x,y:longint); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 普及-的深搜题(不过其实我被坑了很多次) | |
| #### 这道题简单的说只要将坐标、时间、血量一直搜索,搜到边界,血量为零,此坐标有障碍物,或已经走过这个坐标,而如果碰到鼠标(怪异)则回满血(6),还有假如到家则判断最小值,dfs完输出就可以了 | |
| ### 不说了,大家来看看本蒟蒻的代码吧: | |
| ``` | |
| var | |
| n,m,i,j,time_main:longint; | |
| a:array[0..10,0..10] of longint; | |
| b:array[0..10,0..10] of boolean; | |
| procedure dfs(x,y,time,hp:longint); //x和y分别表示行和列坐标,time表示时间,hp表示血量 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### 其实这道题跟 [P1650 田忌赛马](https://www.luogu.org/problemnew/show/P1650) 差不多,只不过田忌赛马求的是最好情况田忌能拿多少银币,而这道泡泡堂让我们求的是最好情况和最坏情况的分数。 | |
| #### 首先肯定是qsort啦,排两遍,把两队的各自从小到大排序—— | |
| #### 那么我们可以这样想,求最好情况时: | |
| - 先用自己队最强的和对方队最强的互怼一下,如果能赢,那么就把分数+2,指针各往后移动一格,进入下一次循环;(比如说下图) | |
|  | |
| - 如果怼不过,那就再拿自己队最弱的和对方队最强的怼,能怼赢,同样的,加上分数,指针往前移一格(比如说下图); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### **~~为数不多的P党~~...** | |
| #### 这道题就是一道dfs,二重循环,每次从有水处(‘W’)开始搜,将搜过的地方赋值为旱地(‘.’),考虑一下边界和有木有搜过,依次往八个方向(i,j-1;i,j+1;i+1,j;i-1,j)搜就可以了(具体看代码注释)。 | |
| $ QAQ $ | |
| #### 代码如下: | |
| ``` | |
| var | |
| n,m,i,j,ans,s:longint; | |
| a:array[0..101,0..101] of char; //字符数组 | |
| procedure dfs(x,y:longint); //神奇的dfs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 一道经典的题目 $ QWQ $ | |
| ### 如果做完这道题,推荐大佬顺便A一下[P2587 [ZJOI2008]泡泡堂](https://www.luogu.org/problemnew/show/P2587),只是在这道题的基础上反着做一遍就可以了。 | |
| ### 要想做这道题,千万别被描述中那最后一段话吓到了...(本蒟蒻直接瘫坐在地上) | |
| ### 相对于泡泡堂,这道题就显得较为简单了。 | |
| ### 首先排序qsort,必须滴----- | |
| ### 然后做的时候分下面三种情况: | |
| - #### 先用自己队最强的和对方队最强的互怼一下,如果能赢,那么就把分数+2,指针各往后移动一格,进入下一次循环;(比如说下图) | |
|  | |
| - #### 如果怼不过,那就再拿自己队最弱的和对方队最强的怼,能怼赢,同样的,加上分数,指针往前移一格(比如说下图); |