一二三四五 上山打老虎

04 2021 档案

摘要:链接:http://118.190.20.162/view.page?gpid=T125 思路:DP,选择类题目考虑DP f[i]定义为前i项中种树的种类数目,f[i]=(f[j]*cnt)(0<=j<i,cnt为[j,i)的种类数),由于题目中不允许把树种在已经存在的位置,对于[j,i),j是已经 阅读全文
posted @ 2021-04-27 18:23 abestxun 阅读(109) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/1336215880692482060 思路:dfs一下每个点到终点的条数,并记录走过的点:如果存在走过的点到达不了终点(也就是线路条数为0)则不满足条件。 代码: #incl 阅读全文
posted @ 2021-04-23 19:00 abestxun 阅读(197) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805073643683840 思路:最短路的变式题 dijk 中vis表示是否被当作过最小点,因为堆中已经有这个点了但是没有被当作最小点过,所有堆中可能存在多个同一个点 阅读全文
posted @ 2021-04-23 08:57 abestxun 阅读(62) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/1336215880692482053 string中find的使用方法; 推荐使用:string str; str.find("smallstr",(int)s);从s处开始 阅读全文
posted @ 2021-04-21 22:26 abestxun 阅读(223) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805106325700608 暴力判素数故意卡i*i<=x 代码: #include<bits/stdc++.h> using namespace std; bool 阅读全文
posted @ 2021-04-21 16:50 abestxun 阅读(105) 评论(2) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805081289900032 思路:首先理解清楚题意:给队员分座位,保证同一个学校的队员不挨着,如果前一个座位的同学是自己学校的,那么隔一个去坐(意思等同于文中,最后剩 阅读全文
posted @ 2021-04-21 16:42 abestxun 阅读(113) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805082313310208 矩阵乘法: for(int i=1;i<=a;i++) for(int j=1;j<=y;j++) for(int k=1;k<=b;k+ 阅读全文
posted @ 2021-04-20 22:18 abestxun 阅读(74) 评论(0) 推荐(0) 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805084284633088 思路: 思路1:模拟乘法,计算为了使当前位为1,应该乘的数为几,需要搜索,程序编写麻烦;//没写出来 思路2:模拟除法, 思路参考链接:h 阅读全文
posted @ 2021-04-20 21:46 abestxun 编辑
摘要:链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805117167976448 反思:这个题中每个人的名称是五位的数字,但是用int类型存储的话只能得到15分,最后两个测试数据过不去;也就是测试数据中可能存在整数值相同 阅读全文
posted @ 2021-04-20 11:19 abestxun 阅读(139) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/1115/ 代码: bfs: #include<iostream> #include<algorithm> #include<queue> using namespace std; char s[25][25]; i 阅读全文
posted @ 2021-04-15 10:49 abestxun 阅读(57) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/1103/ 代码: #include<bits/stdc++.h> using namespace std; using PII=pair<int,int>; int dx[]={0,-1,0,1}; int dy[ 阅读全文
posted @ 2021-04-15 10:44 abestxun 阅读(64) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/1098/ 思路:1:三维bfs:可以分为当前层数内的二维内偏移和层数的一维偏移 代码: #include<iostream> #include<queue> #include<string> #include<cs 阅读全文
posted @ 2021-04-15 10:42 abestxun 阅读(48) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/1235/ 代码: #include<bits/stdc++.h> using namespace std; int k=0,n; char s[1005][1005]; int b[1005][1005]; int 阅读全文
posted @ 2021-04-15 10:38 abestxun 阅读(73) 评论(0) 推荐(0) 编辑
摘要:第22次认证 第一题:简单题 第二题:二维前缀和 第三题:大模拟-DHCP服务器程序模拟 第四题:计数类二维DP? 第五题:图论? 阅读全文
posted @ 2021-04-14 16:12 abestxun 阅读(44) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://www.acwing.com/problem/content/1226/ 思路:离散中的置换群概念,通过当前位置和最终要达到的位置构成环,计算环数k,需要交换的次数为n-k次 #include<bits/stdc++.h> using namespace std; int 阅读全文
posted @ 2021-04-14 16:06 abestxun 阅读(50) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/description/1240/ 代码: #include<bits/stdc++.h> using namespace std; vector<int> a[(int)1e5+5]; map<int,int>mp 阅读全文
posted @ 2021-04-09 08:44 abestxun 阅读(123) 评论(0) 推荐(0) 编辑
摘要:two-pointer 滑动窗口 都是对于l和r分别进行移动,把O(n2)时间复杂度的问题优化到O(n)时间复杂度 模板: //r表示右指针,l表示左指针 for(int r=0,l=0;r<n;r++){ //加入当前右指针的影响 》右指针++,加入产生影响 while(l和r不满足条件,需要左指 阅读全文
posted @ 2021-04-08 17:26 abestxun 阅读(87) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://www.acwing.com/problem/content/1210/ 分类:刚开始给一个状态和若干种操作,通过操作可以转换为另外一个状态,求到目的状态的最小操作数 思路::1:进行搜索找到最短路(dfs,bfs);2:打表找到规律,利用规律求解 规律:每个开关可以控制两 阅读全文
posted @ 2021-04-08 14:54 abestxun 阅读(40) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/118/ 思路:对于每个点只可能存在两种情况:选与不选,对于每个点的选择顺序没有影响,所以可以进行指数枚举后判断即可。 坑点:注意写change函数的时候,(x,y)位置不要改变两次 代码: #include<bit 阅读全文
posted @ 2021-04-08 14:45 abestxun 阅读(52) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/97/ 思路:枚举第一行状态后其余行应该如何操作就确定了,判断最后行和按的次数是否满足条件即可 可以通过位移来模拟按一次改变五个位置的开关,通过异或实现开关。 坑点:要求是把灯全打开,1代表打开 #include<b 阅读全文
posted @ 2021-04-08 10:51 abestxun 阅读(65) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.acwing.com/problem/content/1211/ 备注:观看acwing视频课后总结,思路/总结有所借鉴 思路:num=a+bc,则我们可以枚举任意两个变量,为了防止精度损失,化简除法为乘法=》 \(b=c\times(num- 阅读全文
posted @ 2021-04-07 16:55 abestxun 阅读(65) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T1 思路:要求计算能由S到达的点,但是不能到达T的点的数目。从S点开始dfs一下后标记,然后从T逆向遍历标记。或者从s点开始bfs遍历一遍后把访问的点加到队列中,然后计算队列中能到达T点的数目。 代码: #includ 阅读全文
posted @ 2021-04-06 16:47 abestxun 阅读(91) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T2 注意:组合数利用杨辉三角形递推O(n)求解后是s[n][m],n是大的值,n为1e5用逆元预处理求解,时间复杂度O(nlogn) 代码: #include<bits/stdc++.h> using namespac 阅读全文
posted @ 2021-04-05 22:05 abestxun 阅读(45) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/problem/25084 思路:单调栈的裸变式题目,单调递减的单调栈就是计算其右侧能看到的矩形。 代码: #include<bits/stdc++.h> using namespace std; int main (){ int n; 阅读全文
posted @ 2021-04-05 15:00 abestxun 阅读(39) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://ac.nowcoder.com/acm/problem/15815 题意:让求某个长度为n的数字序列中,所有连续子序列的最大值-最小值之和:len=1len=nMaxnumMinnum 思路:相当于计算a[i]*作为最大值出现的次数-a[i 阅读全文
posted @ 2021-04-05 14:11 abestxun 阅读(51) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T3 思路: 1: 暴力枚举: O(N2) 2: 单调栈 O(N) 代码: #include<bits/stdc++.h> using namespace std; vector<int> ve; int main () 阅读全文
posted @ 2021-04-05 12:53 abestxun 阅读(66) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T51 代码: #include<bits/stdc++.h> using namespace std; int check(int x){ int a=x-3500; int ans=0; ans+=max(0,min 阅读全文
posted @ 2021-04-04 12:01 abestxun 阅读(77) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T52 代码: #include<bits/stdc++.h> using namespace std; map<int,int>mp; int main (){ int n,num; cin>>n; for(int i 阅读全文
posted @ 2021-04-04 11:31 abestxun 阅读(30) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T46 思路:模拟,用20个数组标记这100个座位,分别对连续和不能连续购买座位进行枚举输出。 代码: #include<bits/stdc++.h> using namespace std; int a[25]; in 阅读全文
posted @ 2021-04-04 11:23 abestxun 阅读(50) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T47 代码: #include<bits/stdc++.h> using namespace std; int main (){ int n,num,ans=0; vector<int>ve; cin>>n; for( 阅读全文
posted @ 2021-04-04 10:48 abestxun 阅读(46) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T41 思路:有点坑的大模拟,模拟俄罗斯方块下落的过程,从上到下依次拿小矩形最左边的点去枚举判断,找到当前行可以下落的最低位置后输出 代码: #include<bits/stdc++.h> using namespace 阅读全文
posted @ 2021-04-04 10:43 abestxun 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T42 代码: #include<bits/stdc++.h> using namespace std; vector<int> ve; int main (){ int n,num; cin>>n; for(int i 阅读全文
posted @ 2021-04-03 11:11 abestxun 阅读(49) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T36 注意事项:纵向遍历时注意; 思路: 思路1:把有能够消除的坐标进行加入map标记,这样横纵消除互不影响; 思路2:把能够消除的坐标值标为负数,这样横纵不影响对比,输出也方便判断。 代码: #include<bit 阅读全文
posted @ 2021-04-03 11:01 abestxun 阅读(48) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/12800/G 思路: 输入num 1 2 3 4 5 6 7 8………………num 1 3 5 7 9 11 13………………2num-1 1 4 9 16 25 36 49………………numnum 1 2 4 8 16 阅读全文
posted @ 2021-04-01 22:07 abestxun 阅读(59) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T31 注意:闰年的判断条件:1:年份是4的整数倍,而且不是100的整数倍;2:年份是400的整数倍。两个条件满足之一即可 平年:2月28天,闰年:2月29天 代码: #include<bits/stdc++.h> us 阅读全文
posted @ 2021-04-01 11:38 abestxun 阅读(60) 评论(0) 推荐(0) 编辑
摘要:链接:http://118.190.20.162/view.page?gpid=T32 代码: #include<bits/stdc++.h> using namespace std; int main (){ int n; cin>>n; int num,atm=-1,ans=0; for(int 阅读全文
posted @ 2021-04-01 10:32 abestxun 阅读(51) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示