剑绝尘
剑绝尘
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
剑绝尘的博客
全部文章
(共67篇)
题解 | 小红的字符串构造
#include <bits/stdc++.h> using namespace std; /* 贪心,先用没有被用过的,如果都用过了,就随便找一个和当前字符不一样的,不能构成的条件就是只出现了一种字符 */ string str; map<char,bool> mp; ...
2025-05-08
0
13
题解 | 小美的排列询问
#include <bits/stdc++.h> using namespace std; //扫一遍数组,看看x是否在y的前一个,或者y在x的前一个就行了 const int N = 200001; int n,a[N],x,y; int main(){ cin>&...
2025-05-08
0
13
题解 | 数位染色
#include <bits/stdc++.h> using namespace std; string str; int a[30],len,sum,dp[1000]; int main(){ cin>>str; for(auto x : str){ ...
2025-05-06
0
16
题解 | 买卖股票的最好时机(一)
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int n,dp[N][2],a[N]; //dp[i][0]表示当前没有股票,dp[i][1]表示当前有股票,最后的答案就是dp[n][0] i...
2025-05-06
0
9
题解 | 小美的外卖订单编号
#include <bits/stdc++.h> using namespace std; /* 用x-m小于等于x的最大倍数即可,但是有特殊情况就是m的最大倍数是x,这时编号是0,实际上为m,我们特判一下就行了 */ int main(){ int q; cin>...
2025-05-06
0
12
题解 | 跳跃游戏(一)
#include <bits/stdc++.h> using namespace std; /* 维护最远能到达的地方,如果有一个点不能被到达,那么这个点后面的也不会被到达,直接cout<<false */ const int N = 2e5 + 10; int n,a...
2025-05-05
0
16
题解 | 小红结账
#include <bits/stdc++.h> using namespace std; /* 照着题目模拟,向上取整用库函数ceil(),然后将每次计算的结果累加到s数组中 */ #define int long long const int N = 1e5 + 1; int ...
2025-05-05
0
11
题解 | 拦截导弹
/* ans1为最长递减子序列的长度 根据Dilworth定理:ans2为最少的下降序列个数就等于整个序列最长上升子序列的长度 */ #include <bits/stdc++.h> using namespace std; const int N = 1010; int a[N],d...
2025-05-02
0
14
题解 | 小欧的奇数
/* 题意是说找三个数,能否组成奇数,那其实只有两种组成方法,要么是三个奇数,要么是一个奇数两个偶数 所以我们只要奇数和偶数的数量,最后判断 if(cnt1>=3||(cnt1>=1&&cnt2>=2)) cout<<"YES\n&qu...
2025-05-02
0
12
题解 | 旅游
//这是一题树形dp,dp[cur][0]表示当前不选的最大值,dp[cur][1]表示当前选的最大值,最后dp[s][1]就是答案 #include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int d...
2025-05-02
0
13
首页
上一页
1
2
3
4
5
6
7
下一页
末页