洛谷
AVICIIl
这个作者很懒,什么都没留下…
展开
-
P1631 序列合并(优先队列)
有两个长度都是N的序列A和B,在A和B中各取一个数相加可以得到N^2N 2 个和,求这N^2N 2 个和中最小的N个。原创 2020-04-11 17:18:54 · 223 阅读 · 0 评论 -
P1443 马的遍历
题目链接 #include <cstdio> #include <cstring> #include <queue> using namespace std; struct xy { int x,y; }node,top; int n,m,x0,y0,s[405][405]; const int dx[]={2,2,1,1,-2,-2,-1,-1},dy[]=...原创 2020-02-16 16:31:19 · 101 阅读 · 0 评论 -
P1141 01迷宫
题目链接 用自己想的dfs几个点会超时,需要记忆化搜索 因为能从开头能到达某一点,再次询问过程中走过的点,他们能移动的格子都是一样的。 #include <cstdio> #include <cstring> #define maxn 1005 int n,x0,y0,f[maxn][maxn],ans[1000002]={0}; char a[maxn][maxn]; i...原创 2020-02-16 16:29:31 · 186 阅读 · 0 评论 -
P1032 字串变换
题目链接 这题考察对string的运用和bfs。 #include<iostream> #include<string> #include<queue> #include <map> #include <cstring> #define maxn 15 using namespace std; struct node { string ...原创 2020-02-15 17:02:08 · 92 阅读 · 0 评论 -
P1092 虫食算
题目链接 本题思路是深搜枚举各种情况,用“剪枝的方法”一一排除。 #include <cstdio> #include <stdlib.h> #define maxn 30 int n,flag[maxn],used[maxn]={0},first=1;//flag用来记录字母代表的数字,used记录数字是否用过 char s[4][maxn];//保存算式 int id(...原创 2020-02-15 13:32:21 · 164 阅读 · 0 评论 -
P1040 加分二叉树
题目链接 看不懂题目,直接去看题解了,慢慢琢磨还是不太懂题目的意思,但是能看得懂代码的操作。(好像是遍历各个支点作为根时分数的最大值,然后保存为根 ) #include <cstdio> int n,first=1; long long f[50][50],root[50][50]; long long search(int l,int r) { int k; long long ...原创 2020-02-14 15:37:02 · 124 阅读 · 0 评论 -
P1101 单词方阵
题目链接 这题卡在不会记录路径,比如一个单词读到一半下一个不是了怎么全部归0,还有就是没有注意到要按照同一个方向(准确来说是不会 ) 题解用结构体记录路径,然后在一整个单词串都符合条件的时候用布尔数组将对应的x,y赋值为1,这样全部搜索完之后就可以用是否为1 来输出*或者字母。 #include <cstdio> int n; char aa[101][101],danci[8]={"...原创 2020-02-14 11:52:15 · 137 阅读 · 0 评论 -
P1019 单词接龙
题目链接 不会做看题解一步一步敲,最后竟然还是wa,原来是有一步自己改动给改错了。。 这题是对字符串不会操作,+不会找关系。 #include <iostream> #include <string> #include <cmath> using namespace std; int n,vis[30]={0},yc[30][30]={0}; string tr...原创 2020-02-13 13:50:41 · 133 阅读 · 0 评论 -
P1219 八皇后(深度搜索dfs)
题目链接 首先在b站上学习了一位巨巨的讲解dfs&bfs虽然还是不太懂bfs,但dfs应该没问题了。 这道题主要的点我觉得在于如何判断列,主对角线,副对角线是否有棋子占用(开一个数组来判断这个方法本蒟蒻理解了好长时间。。) #include<cstdio> int qipan[3][100]={0},pos[13],n,count=0; void dfs(int cur) { ...原创 2020-02-13 12:12:04 · 151 阅读 · 0 评论 -
P1012 拼数
题目链接 不会做,完全没思路,不知道要用什么比较方法来判断谁放在哪个位置合适,看了题解发现用类似冒泡的方法+string可以比较!tql. #include <cstdio> #include <cstring> using namespace std; char a[21][1000]; bool cmp(char x[],char y[]) { char a1[10...原创 2020-02-12 12:31:11 · 113 阅读 · 0 评论 -
P1309 瑞士轮
题目链接 几个点超时了,看题解才学会归并(归并排序的思想就是合并两个同序数组的线性方式——每次比较两个有序数组指针指向的值,谁更小(大)则放到temp数组里) #include <cstdio> #include <algorithm> using namespace std; int n,r,q; struct student { long long int s; l...原创 2020-02-10 13:18:04 · 308 阅读 · 0 评论 -
P1068 分数线划定
题目链接 做这道题的时候把我给搞晕了,既要排分数,又要排学号。查看题解后学到了用头文件algorithm中的sort函数,再自定义compar来排分数的同时排学号。 #include<cstdio> #include<math.h> #include<algorithm> using namespace std; struct student { int s;...原创 2020-02-09 12:16:39 · 227 阅读 · 0 评论 -
P1056 排座椅
题目链接 做了一早上!!一直wa,过程中用了2种思路,但越做越混乱,因为题目没认真看。。 注意‘给出最好的通道划分方案’! 但是学习到了桶排,还是值得的。 #include <cstdio> int main() { int M,N,K,L,D,x1,x2,y1,y2,c[1005]={0},o[1005]={0},x[1005]={0},y[1005]={0},p; scanf(...原创 2020-02-07 14:05:00 · 200 阅读 · 0 评论 -
P1478 陶陶摘苹果(升级版)
题目链接 解题过程中不知道最多能摘多少个的意思,以为按照输入顺序判断,看了题解后才知道需要按照花费力气从小到大排序,而且用普通冒泡排序法会超时。所以get到了快速排序的技能! #include <cstdio> int p[2][5001]; void qkst(int l,int r)//快速排序法 { int i,j,mid; i=l;j=r; mid=p[1][(l+r)/...原创 2020-02-06 11:03:23 · 220 阅读 · 0 评论