Frogs and mosquitoes 用线段树维护每个点覆盖的最小id, 用multiset维护没有吃的蚊子. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, in…
这题拖了快一周_(:з」∠)_就把这货单独拿出来溜溜吧~ 本文归属:Educational Codeforces Round 3 题目链接:609F - Frogs and mosquitoes 题目大意:在\(x\)轴上有\(n\)只青蛙,每只青蛙有对应的位置\(x_i\)和他舌头的长度\(t_i\),青蛙可以吃到位置在\([x_i,t_i]\)内的蚊子.\(m\)只蚊子依次降落在位置\(p_i\)上,如果这只蚊子在某只青蛙的攻击范围内,那么他会被这只青蛙吃掉,若有多只青蛙可以吃掉这只蚊子,处…
题目链接 F. Frogs and mosquitoes time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output There are n frogs sitting on the coordinate axis Ox. For each frog two values xi, ti are known — the position a…
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问,最少删除多少个字符,使得串中符合ugly串? 思路:定义dp(i, j),其中i=5,j=5,因为只需要删除2016当中其中一个即可,所以一共所需要删除的字符和需要的字符为20176,因此i和j只要5就够了. 然后转移就是dp(i,i) = 0, 如果说区间大小为1的话,那么如果是2017中的一个…
题目链接: http://codeforces.com/problemset/problem/242/E E. XOR on Segment time limit per test 4 secondsmemory limit per test 256 megabytes 问题描述 You've got an array a, consisting of n integers a1, a2, ..., an. You are allowed to perform two operations on…
题目链接:http://codeforces.com/contest/558/problem/E 题意:有一串字符串,有两个操作:1操作是将l到r的字符串升序排序,0操作是降序排序. 题解:建立26棵线段树,类似计数排序思想. #include <bits/stdc++.h> using namespace std; ; struct SegTree { ], sum[], l, r; }T[N << ]; ][N]; void pushup(int p, int c) { T[p…
Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consisting only of parentheses '(' and ')' is called balanced if it is one of the following. • A string "()" is balanced. • Concatenation of two balance…
D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description When selecting files in an application dialog, Vasya noted that he can get the same selection in different ways. A simple mouse click selects a sing…
题目大意:Codeforces 444C DZY Loves Colors 题目大意:两种操作,1是改动区间上l到r上面德值为x,2是询问l到r区间总的改动值. 解题思路:线段树模板题. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; const int maxn = 5*1e5; typedef long lo…
题目链接:Codeforces 85D - Sum of Medians 题目大意:N个操作,add x:向集合中加入x:del x:删除集合中的x:sum:将集合排序后,将集合中全部下标i % 5 = 3的元素累加求和. 解题思路:线段树单点更新,每一个点维护5个值.分别表示从该段区间中i % 5 = t的和.然后两端区间合并时仅仅须要依据左孩子中元素的个数合并.所以有一个c表示区间上元素的个数. 由于有同样的数.所以要离线操做,将全部的数映射成位置,可是对于del则不须要映射,由于集合中肯定…