
牛客
文章平均质量分 61
Unlimited q
又菜又爱刷题
展开
-
牛客小白月赛34部分题解
A.dd爱科学1.0思路:最长上升(非严格)子序列,DP做法复杂度O(n*26),因为值域只是’A’~'Z’所以速度比贪心快;f[i]表示以s[i]结尾最长的上升序列;last[k]表示上个s[i]==(k+‘A’)的i位置;code:DP#include<bits/stdc++.h>using namespace std;int n;string s;int f[1000010];string t;int last[28];int main(){ cin&g原创 2021-05-31 23:32:47 · 622 阅读 · 1 评论 -
小 Q 与异或DP
链接:https://ac.nowcoder.com/acm/contest/11171/B来源:牛客网小 Q 与异或输入10 101 2 3 4 5 6 7 8 9 101 21 31 52 62 82 103 78 106 91 7输出3377151573157思路:区间结果由区间内两个数决定的DP模板;从小区间枚举到大区间,代码#include<bits/stdc++.h>using namespace std;con原创 2021-04-24 16:45:11 · 174 阅读 · 0 评论 -
牛客练习赛79
牛客练习赛79题目链接A.炼金术师思路:代码B.刀工对决思路代码题目链接A.炼金术师思路:单调栈,题意求布有多少颜色.如果输入3 3 1 2 ,答案是2 因为第3次2会把1覆盖掉;所以每次输入1个数就看前面有没有比他小的数,有就去掉,显然是个单调栈问题.代码#include<bits/stdc++.h>using namespace std;stack<int>stk;int main(){ int n; cin>>n;原创 2021-03-27 14:13:08 · 136 阅读 · 0 评论