![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
暑期训练
文章平均质量分 60
鹤 鸣
这个作者很懒,什么都没留下…
展开
-
搜索(dfs)
DFS 题目:输入一个数字n,输出1~n的全排列。 输入:3 输出:1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 代码: #include<iostream> #include<cstdio> #include<vector> #include<algorithm> using namespace std; int n; vector<int>ans; void show(){ for(int i=0;i<ans原创 2020-07-10 12:16:28 · 83 阅读 · 0 评论 -
单调栈
单调栈模板 stack<int> s; for(int i = 1; i <= n; ++i) { while(s.size() && a[s.top()] >= a[i]) s.pop(); if(s.empty()) l[i] = 0; else l[i] = s.top(); s.push(i); } 应用 1.给定一组数,针对每个数,寻找它和它左边第一个比它小的数之间有多少个数。 2.给定一序列,寻找某一子序列,使得子序列中的原创 2020-07-09 19:48:03 · 78 阅读 · 0 评论 -
The Doctor Meets Vader (Easy)(pair类的使用)
题目链接:------------------------------------- 代码: #include <iostream> #include <algorithm> #include<utility> using namespace std; int main() { int s,b,a[100010]; int i,j; cin>>s>>b; pair<int,int>base[b];//第一原创 2020-07-07 19:57:01 · 121 阅读 · 0 评论 -
New Year Ratings Change(贪心算法)
题目链接------------------------------------------------- 题解: 先对原数列按照从小到大的位置进行排序,并且记录下原来的位置,然后确保新的数列中对应位置上的数为原数列当前数字和未使用过的1-n这些数中最小数字的最大值 代码: #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include <algorithm&g原创 2020-07-07 19:52:47 · 122 阅读 · 0 评论 -
Cinema (map/离散化)
题目链接--------------------------------------------- 翻译:有n个人去看电影,电影一共有m种,n个人会不同的语言,电影的字母和声音是不同的语言,人听到会说的语言或者看到能看懂的语言字母都会很高兴,选择一部电影,让高兴的人最多。 第一种解法: 代码: #include <bits/stdc++.h> using namespace std; const int MAXN = 200010; int a[MAXN],b[MAXN],c[MAXN]原创 2020-07-07 16:24:48 · 541 阅读 · 0 评论 -
Frog Jumps(对边界问题的处理)
题目链接------------------------------------ 题解:只要青蛙一直往右跳,就能成功跳出,为了数据处理的方便,在左右边界分别加上R,该题就变成了寻找字符‘R’的位置差的最大值。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char s[200010]; int main(){ int t,n,i,mx,pre;//pre记录前原创 2020-07-07 16:04:04 · 334 阅读 · 0 评论 -
Misha and Changing Handles (map)
题目链接 ------------------------------------------ 题意:把(a,b)(b,c)保存为(a,c) 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<map> using namespace std; map<string ,string> m; int main() {原创 2020-07-07 15:56:44 · 105 阅读 · 0 评论 -
STL 水果 (map的嵌套当做二维数组)
题目 **水果 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11099 Accepted Submission(s): 4450 Problem Description 夏天来了好开心啊,呵呵,好多好多水果 Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌原创 2020-07-06 22:30:04 · 343 阅读 · 0 评论