rated

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B

跟風遠走 提交于 2020-03-06 06:20:10
/*--> */ /*--> */ Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent. For example, the following three arrays are unimodal: [5, 7, 11, 11, 2, 1], [4, 4, 2], [7], but the following three are not unimodal: [5, 5, 6, 6, 1], [1, 2, 1, 2], [4, 5, 5, 6]. Write a program that checks if an array is unimodal. Input The first line contains integer n ( 1 ≤  n  ≤ 100) — the number of

Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses(tarjan+树的直径)

耗尽温柔 提交于 2020-03-03 00:26:11
题目链接 题意:一条路径上必经的边为关键边,现在让你找一条路径,使得其关键边最多,输出最多的数量。 思路:先缩点,最多的边长肯定是树的直径,模板题。 # include <bits/stdc++.h> using namespace std ; typedef long long ll ; const int maxn = 3e5 + 10 ; int a [ maxn ] , b [ maxn ] , low [ maxn ] , dfn [ maxn ] , vis [ maxn ] , num [ maxn ] , cnt = 0 , sum = 0 , maxx = 0 , id ; vector < int > g [ maxn ] ; stack < int > s ; void tarjan ( int x , int fa ) { low [ x ] = dfn [ x ] = ++ cnt ; vis [ x ] = 1 ; s . push ( x ) ; int flag = 0 ; for ( auto to : g [ x ] ) { if ( to == fa ) { if ( ++ flag < 2 ) continue ; } if ( ! dfn [ to ] ) tarjan ( to , x ) , low [ x ] = min ( low

Educational Codeforces Round 75 (Rated for Div. 2) D. Salary Changing(二分+思维)

两盒软妹~` 提交于 2020-02-20 01:47:29
题目链接 思路:首先肯定是可以想到二分中位数,关键是怎么判断check函数?为了方便我们可以check函数是检查以当前mid为中位数时,大于等于mid的数能否达到n/2+1,注意一下判断细节即可。 # include <bits/stdc++.h> using namespace std ; typedef long long ll ; const int maxn = 2e5 + 1 ; vector < pair < int , int >> v ; int T , n , l , r ; ll s ; bool cmp ( const pair < int , int > & a , const pair < int , int > & b ) { return a . first == b . first ? a . second > b . second : a . first > b . first ; } bool check ( ll x ) //看看是否有n/2+1个数大于x { ll cnt = 0 , sum = 0 ; for ( int i = 0 ; i < v . size ( ) ; ++ i ) { if ( v [ i ] . first <= x && x <= v [ i ] . second ) { if ( cnt < n / 2 + 1

Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-D- Array Restoration

断了今生、忘了曾经 提交于 2020-02-20 01:06:24
我们知道不满足的肯定是两边大中间小的,这样就用RMQ查询两个相同等值的区间内部最小值即可,注意边界条件 #include<bits/stdc++.h> #define x first #define y second #define ok cout << "ok" << endl; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const long double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const double Eps = 1e-7; const int N = 2e5+9; int n, q, a[N], t, pre, pos, l[N]; bool vis[N]; const int MAXN = N; int dp[MAXN][20]; int mm[MAXN]; //初始化RMQ, b数组下标从1开始 void initRMQ(int n) { mm[0] = -1; for

【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) C】

独自空忆成欢 提交于 2020-02-20 00:52:27
【链接】 我是链接,点我呀:) 【题意】 给你一个字符串s. 让你在其中的某一些位置进行操作。。 把[1..i]和[i+1..n]翻转。 使得里面01交替出现的那种子串的长度最长。 【题解】 可以用a,b,c,d,e,f,g依次连在一起。然后a和g再连在一起。形成一个环。。 然后你在这个环上模拟这个操作的过程。 就会发现。不管怎么样。 形成的序列都是下列字符串的一个子串(当然有的时候是反过来的。但会发现正反的话,不影响01串的长度。 abcdefgabcdefg (你会发现在这个环上从a以一定的方向走,总能找到一个按顺序的a,b,c,d,e,f,g.他们的相对位置没有变。 所以在这个扩大了一倍的字符串上做一次01串的查找就好啦 abcdefgabcdefg 【代码】 #include <bits/stdc++.h> #define LL long long #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a;i >= b;i--) #define all(x) x.begin(),x.end() #define pb push_back #define lson l,mid,rt<<1 #define ri(x) scanf("%d",&x) #define rl(x)

Educational Codeforces Round 82 (Rated for Div. 2) D. Fill The Bag

与世无争的帅哥 提交于 2020-02-18 03:22:47
题目链接 大意:给你一些2的幂次数,问你最少分解几次可以用一些2的幂次数得到n。 分解指的是: 2 x − > 2 ∗ 2 x − 1 , x ≥ 0 2^x->2*2^{x-1},x\geq0 2 x − > 2 ∗ 2 x − 1 , x ≥ 0 思路:把n按二进制拆分,从小到大枚举每一位1:先看低位能不能凑齐,否则从高位拆。 细节见代码:(写的比较复杂,理解是很好理解的) # include <bits/stdc++.h> using namespace std ; typedef long long LL ; const int N = 2e5 + 10 ; # define fi first # define se second # define pb push_back int t ; LL n ; int m , a [ N ] ; LL res [ 88 ] ; int fine ( int x , LL num ) { if ( ! num ) return 1 ; if ( x < 0 ) return 0 ; if ( res [ x ] >= num ) { return 1 ; } if ( res [ x ] < num ) { return fine ( x - 1 , ( num - res [ x ] ) << 1 ) ; } } void

文件夹重命名

天涯浪子 提交于 2020-02-17 19:03:14
import os,timepath = r"D:\重命名图片"# files = os.listdir(path)list_url = ["Mainpage","New Products All products(Most Popular)","New Products All products(Featured)","New Products All products(Most Recent)","New Products Dresses(Most Popular)","New Products Dresses(Featured)","New Products Dresses(Most Recent)","New Products Bottoms(Most Popular)","New Products Bottoms(Featured)","New Products Bottoms(Most Recent)","New Products Outwear(Most Popular)","New Products Outwear(Featured)","New Products Outwear(Most Recent)","New Products Rompers Jumpsuits(Most Popular)","New Products Rompers Jumpsuits

Educational Codeforces Round 82 (Rated for Div. 2) - E. Erase Subsequences 一个字符串是否可以拆分成两个序列

五迷三道 提交于 2020-02-15 06:23:55
题目链接:http://codeforces.com/contest/1303/problem/E 题目大意: 给你一个字符串S和一个字符串T。问能不能在S中找到一个子序列S1,然后从S中删除S1.再去删除后的字符串T中再找一个子序列S2。然后用S1+S2拼接成T。 思路:我们枚举T的分割点。进行dp。dp[i][j]:表示前i个字符和t1匹配到第j个字符时。能和t2匹配的最大长度。如果dp[|s|][|t1|]==|t2|就可行。注意t1和t2可能一个为空。特判就可以了。 # include <bits/stdc++.h> # define LL long long using namespace std ; int dp [ 500 ] [ 500 ] ; int check ( char s [ ] , char t1 [ ] , char t2 [ ] ) { memset ( dp , - 1 , sizeof ( dp ) ) ; int n = strlen ( s + 1 ) , n1 = strlen ( t1 + 1 ) , n2 = strlen ( t2 + 1 ) ; dp [ 0 ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { dp [ i ] [ 0 ] = 0 ; for ( int j = 0 ;

Educational Codeforces Round 41 (Rated for Div. 2)

好久不见. 提交于 2020-02-14 20:49:37
这个D可以参考 这个B的思路 A. Tetris time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a following process. There is a platform with n columns. 1 × 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column. When all of the n columns have at least one square in them, the bottom row is being removed. You will receive 1 point for this, and all the squares left will

Educational Codeforces Round 45 (Rated for Div. 2)

╄→尐↘猪︶ㄣ 提交于 2020-02-14 20:49:16
A. C ommentary Boxes 水题 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 5 int main() { 6 LL n, m, a, b; 7 cin >> n >> m >> a >> b; 8 n %= m; 9 LL ans = min(b * n, (m - n) * a); 10 cout << ans << endl; 11 return 0; 12 } Aguin B. M icro-World 双指针 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 2e5 + 10; 4 int a[maxn]; 5 6 int main() { 7 int n, k, ans = 0; 8 scanf("%d %d", &n, &k); 9 for(int i = 1; i <= n; ++i) scanf("%d", a + i); 10 sort(a + 1, a + 1 + n); 11 int p = 1; 12 for(int i = 1; i <= n; i++) { 13 while(p < i && a[p] < a[i] - k) p++; 14