Educational Codeforces Round 68 E. Count The Rectangles 传送门 题意: 给出不超过\(n,n\leq 5000\)条直线,问共形成多少个矩形. 思路: 考虑到\(n\)的范围不大,所以可以暴力枚举两条平行的直线,接下来处理的就是与其垂直的直线的数量. 满足相交成矩形有两个条件,假如我们枚举的直线是垂直于\(x\)轴的,那么两个条件即为\(low\leq y_i\leq high,x_{i,0}\leq left,right\leq x_{i…
Educational Codeforces Round 68 E 题意:有 n 个线段,每个都是平行 x 或者 y 轴,只有互相垂直的两线段才会相交.问形成了多少个矩形. \(n \le 5000, -5000 \le x_i,y_i \le 5000\) key:树状数组 考虑枚举矩形上边和下边,如果统计出与这两条边相交的竖线个数,那么就能知道贡献.先枚举下边,把所有与它相交的竖线插入树状数组.如果把竖线按照上端点的纵坐标排序,那么按照从下往上枚举上边时就可以删掉某些竖边.总复杂度 \(O(…
目录 Contest Info Solutions A.Remove a Progression B.Yet Another Crosses Problem C.From S To T D.1-2-K Game E.Count The Rectangles Contest Info Practice Link Solved A B C D E F G 5/7 O O O O Ø - - O 在比赛中通过 Ø 赛后通过 ! 尝试了但是失败了 - 没有尝试 Solutions A.Remove a…
题目链接:http://codeforces.com/contest/1194                                            A.Remove a Progression time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output You have a list of numbers from 11…
http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace std; ], c[]; ]; int main() { int n, m, q; scanf("%d", &q); while( q-- ) { scanf("%d %d", &n, &m); ; i<n; i++ ) cin>>…
传送门: 1327- E. Count The Blocks  题意:给你一个整数n,求10^n内(每个数有前导零)长度为1到n的块分别有多少个.块的含义是连续相同数字的长度. 题解:从n=1开始枚举,ans数组记录每个长度的块的个数.当前的ans[n]的值就是下一个n++后的ans[n]的值,这样每次只用算长度为1的块有多少个就好了.为了方便,将ans数组倒过来记录.长度为1的块实际上就是总数字个数减去长度为2~n所含有的数字个数.比如n=1时,长度为1的个数有10,当n=2时,长度为1的个数…
A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; int n,x; int main(){ cin>>T; while(T--){ cin>>n>>x; cout<<x * 2<<endl; } return 0; } B. Yet Another Crosses Problem n*m存在上界,…
C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operatio…
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. T…
#include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while(t--){ int n,k; cin>>n>>k; if(k%3==0){ n%=(k+1); if(n==k||n%3) cout<<"Alice"<<"\n"; else cout<<"Bob&…
output standard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one). Players take turns, Alice is first. Each p…
You are given three strings ss, tt and pp consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings. During each operation you choose any character from pp, erase it from pp and insert it into stri…
题意: 从 m 个数中选 n - 1 个数组成先增后减的长为 n 的数组. 思路: 因为 n 个数中有两个数相同,所以每种情况实际上只有 n - 1 个不同的数--$c_m^{n - 1}$, 除去最大数,相同的数有 n - 2 种可能--${n-2}$, 最大数.相同的数排好后,剩余 n - 3 个数可能在最大数左边或右边--${2^{n - 3}}$, 所以答案即为:${(n-2)}{2^{n-3}}c_m^{n-1}$. 对组合数的阶乘公式进行化简,拆分为 n - 1 个分式,使用费马小定…
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能出现一次. 策略: 延伸:这里指的延伸如当发现1-1如果以最后出现重叠的数为右边界则就表示左延伸,若以1.0.1..0第二个0前一个位置作为右边界就为右延伸: 开始时想是右延伸,考虑到可能只出现一组两个数相同,认为向左延伸会出错,但是直接WA了之后,发现这并不是题目的坑点(其实只需将最后一组改成左右…
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 [代码]: #include<bits/stdc++.h> using namespace std; int main() { +]; int maxn,minn; maxn=minn=; cin>>n; ;i<=n;i++) { cin>>a[i]; } ;i&l…
Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Polycarp decided to rewatch his absolute favourite epi…
Educational Codeforces Round 53 E. Segment Sum 题意: 问[L,R]区间内有多少个数满足:其由不超过k种数字构成. 思路: 数位DP裸题,也比较好想.由于没考虑到前导0,卡了很久.但最惨的是,由于每次求和的时候需要用到10的pos次幂,我是用提前算好的10的最高次幂,然后每次除以10往下传参.但我手贱取模了,导致每次除以10之后答案就不同余了,这个NC细节错误卡了我一小时才发现. 代码: #include<iostream> #include<…
Educational Codeforces Round 30  A. Chores 把最大的换掉 view code #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,no-stack-protector") #include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define endl "\n&quo…
Educational Codeforces Round 21  A. Lucky Year 个位数直接输出\(1\) 否则,假设\(n\)十进制最高位的值为\(s\),答案就是\(s-(n\mod s)\) view code #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,no-stack-protector") #include<bits/stdc++.h> using namespac…
Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<voi…
Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性要相同. 由求和公式得k个不同奇数组成的最小数为k2,所以n≥k2. #include <bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; if((n-k)%2==0&&…
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/problem/A 题目给出的条件是 距离为曼哈顿距离,而曼哈顿距离等价于步长. 由题目的一半条件,可以得到步长和为AB步长,各自步长为AB步长的一半. 所以显然可以推出: \[1.如果和为奇数则,不存在\\ 2.如果都为偶数,显然只需要取步长一半即可\\ \] //原始代码 #include<bi…
Educational Codeforces Round 128 (Rated for Div. 2) A-C+E A 题目 https://codeforces.com/contest/1680/problem/A 题解 思路 知识点:思维. 如果 \([l1,r1],[l2,r2]\) 有交集可以是相同的数字,那么取 \(min(l1,l2)\) :如果 \([l1,r1],[l2,r2]\) 没有交集,说明最大值最小值不能是相同的数字,那么取 \(l1+l2\) . 直接判断端点可能太多,…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R andx = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0. 输入 Th…
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. 输入 The only line contains odd integer n (1 ≤ n ≤ 49). 输出 Print n lines…
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal. 输入 The first line contains integer n (1 ≤ n ≤ 3·105)…
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and dis the row from '1' to '8'. Find the number of moves perm…
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数,并输出方案与公倍数. solution 枚举每一个数,将它的倍数的答案加一,最大值就是答案. 时间复杂度:\(O(nlogn)\) Thief in a Shop 题目描述:给出\(n\)中物品与它们的价值,每种物品都有无限个,问从中拿出\(m\)个,价值有可能是什么,输出所有的价值. soluti…
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. Water The Garden 题意:给你一个长度为\(n\)的池子,告诉你哪些地方一开始有水, 每秒可以向左和向右增加一格的水, 问什么时候全部充满水.(\(n \le 200\)) 题解:按题意模拟.每次进来一个水龙头,就更新所有点的答案 (取\(min\)).最 后把所有点取个\(max\)就…