摘要: 做了一道对顶堆(反过来的)的练习。。很水 #include<bits/stdc++.h> using namespace std; const int N=200005; priority_queue<int,vector<int>,greater<int> >Q2; priority_queue< 阅读全文
posted @ 2018-12-17 20:25 lqsno1 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 由于看不懂poj的输出,就用luogu的对顶堆代替吧! #include<bits/stdc++.h> using namespace std; const int N=100010; priority_queue<int,vector<int>,greater<int> >Q1; priority 阅读全文
posted @ 2018-12-17 20:06 lqsno1 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 交了N发后终于A了。。。 发一波dalao的题解: 某状态的奇偶性定义为逆序对(不包括0的)总数的奇偶性。 某状态的奇偶性定义为逆序对(不包括0的)总数的奇偶性。 此题目终态为偶数 首先,0的左右移动不改变奇偶性。 1.N为奇数,上下移动不改变奇偶性,故逆序数为偶的YES 2.N为偶数,上下移动逆序 阅读全文
posted @ 2018-12-17 16:56 lqsno1 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 和糖果传递差不多。我是不是眼瞎啊,m写成n都看不出来了 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=100005; ll r[N],c[N]; int main(){ int n,m,T 阅读全文
posted @ 2018-12-17 15:52 lqsno1 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 挺有趣的。观察题目环形?切掉一个跑贪心?O(n^2)超时了。。。 先计算m为每个最终糖果数量。 设An传给A1了k个糖果, 那么A1传给A2的糖果数为S1=k+A1-m,T1=A1-m 那么A2传给A3的糖果数为S2=k+A1+A2-2*m ,T2=A1+A2-2*m 那么A3传给A4的糖果数为S3 阅读全文
posted @ 2018-12-17 15:05 lqsno1 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 二分答案+判定 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; const double eps=1e-5,inf=999999999; int n,ll; double t[maxn],a[maxn],sum[m 阅读全文
posted @ 2018-12-17 10:30 lqsno1 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 考虑递推。 d[i]表示在三塔的情况下 d[i]=d[i-1]*2+1 f[i]表示在四塔的情况下 f[i]=f[j]*2+d[i-j] (1<=j<i) #include<cstdio> using namespace std; inline int min(int a,int b){return 阅读全文
posted @ 2018-12-17 10:26 lqsno1 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 分形图,就是找规律。。。 #include<iostream> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; typedef pair<ll,ll> P; P get_(int n,int 阅读全文
posted @ 2018-12-17 10:10 lqsno1 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 水题(差分即可),注意判重 #include<iostream> #include<algorithm> #include<map> using namespace std; typedef long long ll; map<pair<int,int>,bool>exist; const int 阅读全文
posted @ 2018-12-17 09:00 lqsno1 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 描述 给定一个长度为 n(n≤10^5 ) 的数列 {a_1,a_2,…,a_n},每次可以选择一个区间 [l,r],使下标在这个区间内的数都加一或者都减一。求至少需要多少次操作才能使数列中的所有数都一样,并求出在保证最少次数的前提下,最终得到的数列可能有多少种。 输入格式 第一行一个正整数n。接下 阅读全文
posted @ 2018-12-17 08:34 lqsno1 阅读(243) 评论(0) 推荐(0) 编辑