- 博客(91)
- 收藏
- 关注
转载 南昌网络赛 H The Nth Item
南昌网络赛The Nth Item 暴力快速幂+unordered_map记忆化 注意:记忆化不能写到快速幂求解函数里,不断调用函数会造成很大的时间浪费 #include<bits/stdc++.h> using namespace std; #define sc(x) scanf("%lld",&x); #define si signed #d...
2019-09-09 14:37:00
197
转载 Who is better?
徐州网络赛A 所谓斐波那契博弈 考场推了个假规律自闭== import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; public class Main { static BigInteger m[]=new BigInteger[...
2019-09-07 18:38:00
201
转载 D. Treasure Island
D. Treasure Island dfs大法好== 写半天bfs疯狂MLE dfs标记掉路上的一些点 然后再跑一遍dfs #include<bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%I64d",&x); #define rea...
2019-09-04 21:55:00
297
转载 南京网络赛 E K Sum
K Sum 终于过了这玩意啊啊啊==== 莫比乌斯反演,杜教筛,各种分块,积性函数怎么线性递推还很迷==,得继续研究研究 #include<bits/stdc++.h> using namespace std; #define int long long #define maxn 1000000+10 int P[maxn],g[maxn]; bool v...
2019-09-04 10:55:00
157
转载 南京网络赛C
分段打表大法好!!! 打表40min,A题1s https://nanti.jisuanke.com/t/41300 #include<bits/stdc++.h> #define int long long using namespace std; #define mod 998244353 const int maxn=100000+2; int P[...
2019-09-02 16:08:00
335
转载 2019 南京网络赛A
南京网络赛自闭现场 https://nanti.jisuanke.com/t/41298 二维偏序经典题型 二维前缀和!!! #include<bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%lld",&x); int T; #defi...
2019-09-01 18:44:00
106
转载 D2. Equalizing by Division (hard version)
D2. Equalizing by Division (hard version) 涉及下标运算一定要注意下标是否越界!!! 思路,暴力判断以每个数字为到达态最小花费 #include<bits/stdc++.h> using namespace std; #define sc(x) scanf("%I64d",&x); #define read...
2019-08-31 08:25:00
174
转载 P3379 【模板】最近公共祖先(LCA)
P3379 【模板】最近公共祖先(LCA) LCA模板 询问离线 tarjan算法 #include<bits/stdc++.h> using namespace std; vector<int> v[500000+5]; int N,M,root; bool vis[500000+5]; struct Q { int x,y; ...
2019-08-30 18:57:00
125
转载 【模板】线段树 2
【模板】线段树 2 乘法懒标等于0也要下传,每次乘法操作对加法也要进行 #include<bits/stdc++.h> using namespace std; #define int long long const int maxn=1e5+10; int v[maxn*4],L[maxn*4],R[maxn*4],lazy1[maxn*4],lazy2[...
2019-08-30 08:31:00
126
转载 B. Array K-Coloring
B. Array K-Coloring 给定一个数组 要求对元素进行染色,满足相同元素颜色一定不同,且所有颜色要全部用完 #include<bits/stdc++.h> using namespace std; #define sc(x) scanf("%I64d",&x); #define int long long vector<int&g...
2019-08-28 12:40:00
280
转载 D. Print a 1337-string...
D. Print a 1337-string... 输出一个字符串 里面包含n个子序列 1337 #include<bits/stdc++.h> using namespace std; #define sc(x) scanf("%I64d",&x); #define int long long int t,n; int C[100005]; v...
2019-08-28 11:57:00
163
转载 P2962 [USACO09NOV]灯Lights
P2962 [USACO09NOV]灯Lights guass消元异或方程组 #include<bits/stdc++.h> using namespace std; #define maxn 100 #define sc(x) scanf("%lld",&x); #define int long long int A[maxn][maxn]; i...
2019-08-27 13:58:00
148
转载 P1041 传染病控制
https://www.luogu.org/problem/P1041 #include<bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%lld",&x); const int maxn = 1000; int n,m,tot=1,ans=5...
2019-08-27 11:52:00
213
转载 B. Uniqueness
B. Uniqueness 给定一个序列,要求删除一段连续子段,满足删掉子段后每个元素唯一 求最小子段长度 枚举起点,二分子段长度 记得先sort 再unique #include<bits/stdc++.h> using namespace std; #define int long long #define si signed #define end...
2019-08-26 10:44:00
253
转载 D. Restore Permutation
D. Restore Permutation 就是给一个n个数的全排,然后bi记录比ai小且在排在ai前面的数的和,求ai 树状数组维护,二分 #include<bits/stdc++.h> using namespace std; #define int long long #define si signed #define endl '\n' #d...
2019-08-26 10:39:00
266
转载 array
array 权值线段树 查询剪枝 疯狂RE #include<bits/stdc++.h> using namespace std; #define int long long #define maxn 100000+500 #define inf n+1 int L[maxn*4],R[maxn*4],V[maxn*4]; int A[maxn],B...
2019-08-24 11:30:00
134
转载 Anniversary party
Anniversary party 树形dp dp[i][0]=(i的全部员工的max(dp[u][1],dp[u][0)相加,也就是其子员工来或不来的最大快乐值。 dp[i][1]=(i的全部员工的dp[u][0相加,也就是其子员工都不能不来的最大快乐值。 #include <cstdio> #include <iostream> #includ...
2019-08-22 15:25:00
176
转载 1358. 分割树
1358. 分割树 现在有一棵树T,有N个节点,我们想通过去掉一个节点p来把T分割成更小的树,并且满足每个小树中的节点数不超过n/2。 请根据输入的树来输出所有可能的p的号码。 树形dp 在遍历树的过程中,访问每个node,维护两个值: 所有子树的结点数的最大值childmax 所有子树(这里包括node)的结点数之和sum。 递归过程中用上一层的sum,不断更新这...
2019-08-22 14:52:00
1100
转载 Tree and Permutation
Tree and Permutation 给出一个1,2,3...N的排列,显然全部共有N!种排列,每种排列的数字代表树上的一个结点,设Pi是其中第i种排列的相邻数字表示的结点的距离之和,让我们求sum(Pi)(1<=i<=N!)。 可以设dis(i, j)为树上任意两点间的最短距离,每两点之间的距离都出现了 (N-1)!次,所求答案为 (N-1)! * sum(dis(...
2019-08-22 14:41:00
210
转载 码队的新桌游
码队的新桌游 树状数组、离散化、二维偏序 #include <bits/stdc++.h> ///即找x.a<y.b<x.c&&y.a<x.b<y.c的组数 using namespace std; struct Item { int a, b, c; int id; int ans; ...
2019-08-22 11:36:00
129
转载 关于优先队列重载运算符
struct Item { int a, b, c; int id; int ans; explicit Item(int _a = 0, int _b = 0, int _c = 0) : a(_a), b(_b), c(_c) {} }; struct cmpa { bool operator()(const Item...
2019-08-22 11:03:00
211
转载 YJJ's Salesman
YJJ's Salesman YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.One day, he is going to travel...
2019-08-21 22:58:00
235
转载 E. Natasha, Sasha and the Prefix Sums
http://codeforces.com/contest/1204/problem/E 给定n个 1 m个 -1的全排 求所有排列的$f(a)=max(0,max_{1≤i≤l} \sum_{j=1}^{i}a_{j} )$之和 组合数,枚举 #include <bits/stdc++.h> using namespace std; typed...
2019-08-21 10:58:00
174
转载 C. Anna, Svyatoslav and Maps
C. Anna, Svyatoslav and Maps 给定一个有向图,给定一条有向路径,求一条顶点最少的路径,使得给定的路径是它的最短路 folyd预处理出任意两点间的最短路,然后判断是否可以缩点 #include<bits/stdc++.h> using namespace std; #define int long long typedef long ...
2019-08-21 09:45:00
208
转载 D1. Kirk and a Binary String (easy version)
D1. Kirk and a Binary String (easy version) 01串找最长不降子序列 给定字符串s,要求生成一个等长字符串t,使得任意l到r位置的最长不降子序列长度一致 从后往前暴力枚举,枚举每个一替换成0后是否改变了l到r位置的最长不降子序列长度 01串的最长不降子序列,可以通过线性dp求解 dp i表示以i结尾的最长不降子序列长度 dp[0]=d...
2019-08-21 08:58:00
264
转载 C. Almost Equal
C. Almost Equal n个数字全排成一个圈,满足任意相邻n个之和之间最大最小值之差不超过1 n为偶数时 不存在 n为奇数,构造 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define sc(x) scanf("%I64d",&x); #defi...
2019-08-19 10:10:00
191
转载 D. Shortest Cycle
D. Shortest Cycle A[i]&A[j]!=0连边, 求图中最小环 N>128 时必有3环 其他暴力跑 folyd最小环 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define sc(x) scanf("%I64d",&x);...
2019-08-19 09:44:00
184
转载 Coffee Chicken
Coffee Chicken 字符串斐波那契 输出第s[n]个字符串的第k位及后十位 暴力算出前20项,超过20,跑dfs #include<bits/stdc++.h> using namespace std; string s[1000]; typedef long long ll; ll n,k; ll A[500]; string _s[...
2019-08-17 20:51:00
118
转载 Han Xin and His Troops
Han Xin and His Troops 中国剩余定理 JAVA板子 /*中国剩余定理,根据公式需要求取大数的逆元*/ import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; public class Main { static...
2019-08-17 20:42:00
172
转载 D - Find Integer
D - Find Integer $a^{n}+b^{n}=c^{n}$ 给定a,n求解$b,c$ 三次以上没有整数解 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll A[500005]; ll n,a; int main() { int T;...
2019-08-17 09:53:00
161
转载 HDU 6438 Buy and Resell
高卖低买,可以交易多次 维护一个优先队列,贪心 相当于每天卖出 用当前元素减优先队列最小得到收益 用0/卖出,1/买入标志是否真实进行了交易,记录次数 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll A[500005]; #define P pair<...
2019-08-17 09:27:00
118
转载 Xyjj’s sequence
Xyjj’s sequence #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; const ...
2019-08-16 23:40:00
139
转载 Planting Trees
Planting Trees 给定N*N矩阵,求子矩形满足里面最大元素最小元素之差不超过M 单调队列 枚举上边界,下边界,及右边界, 用两个单调队列,一个维护最大值,一个维护最小 求左边界 #include<bits/stdc++.h> using namespace std; int A[505][505]; #define sc(x) scanf...
2019-08-16 17:28:00
280
转载 All-one Matrices
All-one Matrices 单调栈 最大全一矩阵计数 #include<bits/stdc++.h> #define maxn 3005 using namespace std; #define P pair<int,int> int n,m,ans,H[maxn][maxn],pre[maxn][maxn]; stack<P&...
2019-08-16 11:22:00
90
转载 Beauty Values
Beauty Values 题意:给$n$个数, 定义它的Beauty Values为所有连续子区间的(区间长度*区间内不同数字的数目)求和 求Beauty Values A[i]数组表示数字i最近一次出现在什么时候,增加一个数字i,A[i]之前引起的只是区间长度的变化,数字种类没有增加, dp[i]记录i和i-1之间的ans差 #include<bits/stdc...
2019-08-15 22:06:00
162
转载 BM板子
BM线性递推 玄学玩意 struct LinearRecurrence { using int64 = long long; using vec = std::vector<int64>; static void extand(vec& a, size_t d, int64 value = 0) { ...
2019-08-15 18:36:00
205
转载 Knapsack Cryptosystem
Knapsack Cryptosystem 超大背包 折半查找 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll,int> ll A[39]; ll C[39]; bool B[39]; ll s,_n; vect...
2019-08-15 18:21:00
166
转载 All men are brothers
All men are brothers 牛客多校第九场E 给定n个人,起初互不认识 然后m各阶段 每个阶段有两个人x、y认识 求每个阶段选出四个人互不认识的方式 并查集 #include<bits/stdc++.h> using namespace std; typedef unsigned long long ll; ll f[100004]...
2019-08-15 18:16:00
183
转载 Quadratic equation
Quadratic equation 牛客多校九B 给定 $(x+y)\%mod=b$ $(x*y)\%mod=c$ 求 $x,y$ 二次剩余 求$((x-y)^{2})\%mod = (b\times b-4\times c)\%mod$ #include<bits/stdc++.h> using namespace std; typedef lon...
2019-08-15 18:03:00
284
转载 B. Equal Rectangles
B. Equal Rectangles 给定4*N个数,是否能构成N个矩形 面积均相等 每次取两个大的,两个小的 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define sc(x) scanf("%I64d",&x); #define read(A) fo...
2019-08-14 22:48:00
105
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅