模拟题,运用强大的stl. #include <iostream> #include <map> #include <algorithm> #include <set> #define N 150005 using namespace std; typedef long long Int; ; map<long long, set<int> > mapp; long long a[N]; int main() { int n; cin…
D. Merge Equals time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an array of positive integers. While there are at least two equal elements, we will perform the following operatio…
http://codeforces.com/contest/962/problem/D D. Merge Equals time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array of positive integers. While there are at least two equal…
A. Equator(模拟) 找权值的中位数,直接模拟.. 代码写的好丑qwq.. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; ; inline int read() { , f = ; ; c = getchar();} + c - ', c = getchar(); return x * f; } int N; in…
题目链接: https://codeforces.com/contest/1093/problem/G 题目: 题意: 在k维空间中有n个点,每次给你两种操作,一种是将某一个点的坐标改为另一个坐标,一种操作是查询[l,r]中曼哈顿距离最大的两个点的最大曼哈顿距离. 思路: 对于曼哈顿距离,我们将其绝对值去掉会发现如下规律(以二维为例): 故这题我们可以用线段树来维护[l,r]中上述每种情况的最大值和最小值,用二进制来枚举xy的符号(1为正,0为负),最后答案是 每种情况中区间最大值-区间最小值…
题目链接:https://codeforc.es/contest/1202/problem/B 题意: 给你一串数,问你插入最少多少数可以使x-y型机器(每次+x或+y的机器,机器每次只取最低位--%10)产生这个子序列. 解: 这题真的是...唉我真的,还是怪自己太弱吧,比如08888,8和前一个8相同的话你必须让机器输入东西(不能看着这串数反正都是一样就不输入). 就是预处理x-y型每次加(0~9)最少需要多少次就行了,刚上蓝就rank1900+,以后多多磨练吧. #define IOS i…
E. Byteland, Berland and Disputed Cities time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The cities of Byteland and Berland are located on the axis Ox. In addition, on this axis there are also…
DFS,把和当前结点相连的点全都括在当前结点左右区间里,它们的左端点依次++,然后对这些结点进行DFS,优先对左端点更大的进行DFS,这样它右端点会先括起来,和它同层的结点(后DFS的那些)的区间会把它括起来,这样它们就不会相交了. #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; vector<]; ],r[]; void dfs(int x,int fa){ ;i<v[x].s…
#include <vector> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; ; ll x[N], y[N]; int n; bool gx(int a, int b, int c, int d) { return (x[b] - x[a])*(y[d] - y[c]) == (x[d] - x[c])*(y[b] - y[a]); } int…
//暴力 #include <iostream> #include <algorithm> #include <string> using namespace std; ; string s1[N], s2[N], s3[N], s4[N]; int a[N][N], b[N][N]; int main() { int n; cin >> n; ; i<n; i++) cin >> s1[i]; cin.get(); ; i<n; i…