剑绝尘
剑绝尘
全部文章
分类
题解(2)
归档
标签
去牛客网
登录
/
注册
剑绝尘的博客
全部文章
(共69篇)
题解 | 【模板】二分
#include <bits/stdc++.h> using namespace std; inline int read(){ int s = 0,w = 1;char c= getchar(); while(!isdigit(c)) w = c =='-' ...
2025-05-29
0
16
题解 | 小红的区间查询
#include <bits/stdc++.h> using namespace std; const int N = 210; int n,q,a[N],s[N][N]; void add(int l,int x,int k){ for(int i = l;i&l...
2025-05-16
0
31
题解 | 小红的字符串构造
#include <bits/stdc++.h> using namespace std; /* 贪心,先用没有被用过的,如果都用过了,就随便找一个和当前字符不一样的,不能构成的条件就是只出现了一种字符 */ string str; map<char,bool> mp; ...
2025-05-08
0
40
题解 | 小美的排列询问
#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
41
题解 | 数位染色
#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
40
题解 | 买卖股票的最好时机(一)
#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
24
题解 | 小美的外卖订单编号
#include <bits/stdc++.h> using namespace std; /* 用x-m小于等于x的最大倍数即可,但是有特殊情况就是m的最大倍数是x,这时编号是0,实际上为m,我们特判一下就行了 */ int main(){ int q; cin>...
2025-05-06
0
28
题解 | 跳跃游戏(一)
#include <bits/stdc++.h> using namespace std; /* 维护最远能到达的地方,如果有一个点不能被到达,那么这个点后面的也不会被到达,直接cout<<false */ const int N = 2e5 + 10; int n,a...
2025-05-05
0
30
题解 | 小红结账
#include <bits/stdc++.h> using namespace std; /* 照着题目模拟,向上取整用库函数ceil(),然后将每次计算的结果累加到s数组中 */ #define int long long const int N = 1e5 + 1; int ...
2025-05-05
0
21
题解 | 拦截导弹
/* ans1为最长递减子序列的长度 根据Dilworth定理:ans2为最少的下降序列个数就等于整个序列最长上升子序列的长度 */ #include <bits/stdc++.h> using namespace std; const int N = 1010; int a[N],d...
2025-05-02
0
35
首页
上一页
1
2
3
4
5
6
7
下一页
末页