580A - Kefa and First Steps 思路:dp dp[i]表示包括前i个元素中a[i]在内的最大增序列. 代码: #include<bits/stdc++.h> using namespace std; ; int a[N]; int dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(); int n; cin>>n; dp[]=; ; ;i<n;i++)cin>>a[i]; ;i…
A. Kefa and First Steps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/problem/A Description Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) h…
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 …
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 …
题目链接:http://www.codeforces.com/problemset/problem/580/A题意:求最长连续非降子序列的长度.C++代码: #include <iostream> using namespace std; ; int n, a[maxn], tmp, ans; int main() { cin >> n; ; i < n; i ++) cin >> a[i]; tmp = ans = ; ; i <= n; i++) ])…
题目链接:http://codeforces.com/contest/580/problem/C #include<cstdio> #include<vector> #include<cstring> #define MAX 100010 using namespace std; vector <int> a[MAX]; int visit[MAX]; int cat[MAX]; int leaf[MAX]; int ans,m; void dfs(int…
805D - Minimum number of steps 思路:简单模拟,a每穿过后面一个b,b的个数+1,当这个a穿到最后,相当于把它后面的b的个数翻倍.每个a到达最后的步数相当于这个a与它后面已经到达最后的a之间的b的个数,只要从后面往前扫,记录b的个数,每遇到一个a,把b的个数加入答案,并且b的个数翻倍. 代码: #include<bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; ; ; int main()…
Kefa and Watch Problem's Link Mean: 给你一个长度为n的字符串s,有两种操作: 1 L R C : 把s[l,r]全部变为c; 2 L R d : 询问s[l,r]是否是周期为d的重复串. analyse: n最大为1e5,且m+k最大也为1e5,这就要求操作1和操作2都要采用logn的算法,所以用线段树. 对于更新操作,使用区间更新就可解决. 主要是如何在logn的时间内完成询问操作. 我们采用线段树维护hash值的方法. 结合于类似KMP的性质,我们发现,字…