- 博客(208)
- 收藏
- 关注
原创 hdu 3966(树链剖分)
Aragorn's StoryTime Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9622 Accepted Submission(s): 2535Problem DescriptionOur p
2016-10-20 12:50:15 448
原创 poj 3277(线段树+离散化)
City HorizonTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 18646 Accepted: 5145DescriptionFarmer John has taken his cows on a trip to the city! As the
2016-10-13 12:04:13 550
原创 cf 686 B
链接:http://codeforces.com/problemset/problem/686/B#include using namespace std;int a[200];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); for(in
2016-07-15 21:56:26 1321
原创 cf 682 C (树形dp)
链接:http://codeforces.com/problemset/problem/682/C dp[v]表示以v为终点所需消耗的最大值 当d[v]大于a[v]时就删除以v为根节点的子树#include using namespace std;#define ll long longconst int N=1e5+5;vector >G[N];ll n,a[
2016-07-15 21:54:29 864
原创 cf 697 A
链接:http://codeforces.com/problemset/problem/697/A#include using namespace std;int main(){ int n,m,k; scanf("%d%d%d",&n,&m,&k); if(k<n)printf("NO\n"); else if(k==n)printf("YES
2016-07-15 21:50:28 466
原创 cf 697 B(模拟)
链接:http://codeforces.com/problemset/problem/697/B 直接按题意模拟。。。#include using namespace std;char s[100000],d[100000],e[100000];int main(){ int a,b; while(~scanf("%s",s)){ sscanf(s,"%d.
2016-07-15 21:48:48 651
原创 cf 697 C
链接:http://codeforces.com/problemset/problem/697/C 每次操作都查找两点的最近的公共祖先,查找的同时更新路径权值或者求最短路径代价#include using namespace std;#define ll long longmap,ll>m;int main(){ int n; scanf("%d",&n)
2016-07-15 21:47:01 867
原创 cf 686 D
链接:http://codeforces.com/problemset/problem/686/D 寻找以i为根的子树的重心 当我们要求ans[i]的时候可以发现ans[i]一定会在i节点儿子中数量最多的子树当中,所以层层往上推 直到ans[i]=i || d[i]-d[ans[i]]#include using namespace std;const int N=3e5+
2016-07-15 21:44:00 1896
原创 cf 681 C(模拟)
链接:http://codeforces.com/problemset/problem/681/C 优先队列去模拟#include using namespace std;priority_queue,greater >q;char s[100],ss[100];vectorv;int main(){ int n,val; scanf("%d",&n);
2016-07-15 21:34:01 969
原创 poj 3140(树形dp)
Contestants DivisionTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9349 Accepted: 2676DescriptionIn the new ACM-ICPC Regional Contest, a special moni
2016-07-14 17:10:59 272
原创 poj 1655(树形dp)
Balancing ActTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11953 Accepted: 5033DescriptionConsider a tree T with N (1 <= N <= 20,000) nodes numbered 1
2016-07-14 17:08:05 211
原创 poj 2378(树形dp)
Tree CuttingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4316 Accepted: 2627DescriptionAfter Farmer John realized that Bessie had installed a "tree-s
2016-07-14 17:04:41 239
原创 poj 3107(树形dp)
GodfatherTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 5860 Accepted: 2052DescriptionLast years Chicago was full of gangster fights and strange murd
2016-07-14 17:00:42 224
原创 hdu 3586(树形dp+二分)
Information DisturbingTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 2540 Accepted Submission(s): 901Problem Description
2016-07-14 16:54:14 275
原创 hdu 2196(树形dp)
ComputerTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5508 Accepted Submission(s): 2748Problem DescriptionA school boug
2016-07-14 16:47:26 293
原创 hdu 1520(树形dp)
Anniversary partyTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8730 Accepted Submission(s): 3772Problem DescriptionTher
2016-07-14 16:25:04 258
原创 cf 689 D(线段树+二分)
链接:http://codeforces.com/problemset/problem/689/D#include using namespace std;#define ll long longconst int maxn=2e5+10;struct tree{ int l,r; int a,b,ma,mi;}tree[3*maxn];int a[max
2016-07-12 19:27:47 335
原创 cf 102 A(暴力)
链接:http://codeforces.com/problemset/problem/102/A#include using namespace std;int a[105],ma[105][105];int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) sca
2016-07-12 19:25:33 280
原创 cf 437 D(并查集)
链接:http://codeforces.com/problemset/problem/437/D 两个集合A,B的个数分别n,m,当着两个集合通过f(a,b)连通时f(a,b)是最小的边,题目结果为n*m*f(a,b)*2 所以可以将边从大到小排序之后,用并查集维护并计算个数#include using namespace std;#define ll long lo
2016-07-12 19:22:26 324
原创 cf 689 C(二分)
链接:http://codeforces.com/problemset/problem/689/C#include using namespace std;#define ll long longll get(ll n){ ll ans=0; for(ll k=2;k*k*k<=n;k++) ans+=n/(k*k*k); return
2016-07-12 19:14:31 346
原创 cf 689 A
链接:http://codeforces.com/problemset/problem/689/A 直接将给的向量四个方向平移一次看是否有符合的#include using namespace std;#define ll long longconst int maxn=1e5+10;int n;char s[maxn],str[maxn];int flag[4]
2016-07-12 19:11:52 697
原创 cf 689 B(最短路)
链接:http://codeforces.com/problemset/problem/689/B #include using namespace std;#define ll long longconst int maxn=2e5+10;const int inf=(1<<30);vectorve[maxn];int n;//fuc
2016-07-12 19:09:41 629
原创 cf 337 D(dfs)
链接:http://codeforces.com/problemset/problem/337/D 找到已经被攻击的最远距离的两个点,再遍历其他点到这两点之间的距离,当两点之间的距离都小于d,这符合题意 #include using namespace std;const int maxn=1e5+5;int n,m,d;int a[maxn],dist1[maxn],dist
2016-07-12 19:06:23 1215
原创 cf 432 C
链接:http://codeforces.com/problemset/problem/432/C 任意一个大于2的合数等于两个素数相加,只要知道这个定理就不难了。将每个元素的值作为下标,记录该元素所在的位置,排序的时候判断该点是否为本身,不是得话就去判断两点之间的距离是否为素数,不是变为两个素数相加即可,具体看代码#include usi
2016-07-12 19:01:23 390
原创 cf 75 C(gcd)
链接:http://codeforces.com/problemset/problem/75/C 求出a,b的gcd c,求出c的因子,判断是否在区间中#include using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int arr[10000];int main(
2016-07-12 18:51:24 421
原创 cf 488 B(暴力)
链接:http://codeforces.com/problemset/problem/488/B#include using namespace std;int a[10],b[10];int judge(){ sort(b,b+4); if(b[3]==3*b[0]&&b[2]+b[1]==4*b[0]) return 1; els
2016-07-12 18:47:39 221
原创 cf 260 C(模拟)
链接:http://codeforces.com/problemset/problem/260/C 思路:模拟往回推的过程,正常肯定超时,所以可以先将数据中的最小值取出,将每一个数都减去这个最小值,再模拟就好#include using namespace std;#define ll long longll a[100005];int main(){ ll n
2016-07-12 18:39:31 344
原创 cf 551 C(二分)
链接: http://codeforces.com/problemset/problem/551/C 思路:二分查找所需的时间t,m个人都有t个单位的时间,从后往前清空,直到答案最优#include using namespace std;#define ll long longint a[100005],b[100005];int main(){ in
2016-07-12 18:32:12 533
原创 cf 44 A
链接:http://codeforces.com/problemset/problem/44/A直接判重#include using namespace std;string s1,s2;map,int> m;int main(){ int n; scanf("%d",&n); while(n--) { cin>>s1>>s2;
2016-07-12 18:18:17 275
原创 cf 305 C(模拟)
链接: http://codeforces.com/problemset/problem/305/C 模拟下求解的过程,当ai == aj 时 两个合并为ai+1,最后模拟完可以发现 答案为 合并后的最大值-合并后的个数+1...具体看代码#include using namespace std;#define ll long longsets;int mai
2016-07-12 18:16:26 254
原创 cf 55A(暴力 )
链接:http://codeforces.com/problemset/problem/55/A 直接暴力 ..#include using namespace std;#define ll long longconst int maxn=100005;mapm;int main(){ int n; scanf("%d",&n); ll res
2016-07-12 17:45:42 192
原创 cf 87 A
链接:http://codeforces.com/problemset/problem/87/A 模拟下就知道了。。#include using namespace std;#define ll long longll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}int main(){ ll a,
2016-07-11 09:59:02 282
原创 cf 433 C(思维题)
链接:http://codeforces.com/problemset/problem/433/C 思路:可以先计算总的消耗,接着计算将某一类型的所有数字更换成相邻的数字之后所降低消耗的最大值。。可以枚举每一个数换成相邻的数字之后减低的消耗,正常枚举肯定会超时。所以需要我们先求出每一个相邻数字的前缀和,接着枚举一个可以用o(1)的时间算出降低的消耗,具体看代码#
2016-07-11 09:52:29 494
原创 cf 680 c
链接:http://codeforces.com/contest/680/problem/C题意:给你一个数字,让你查询不超过20次判断是素数还是合数//判断2 -100 以内是素数还是合数 由于最多查询20次 我们可以查询20次来判断是否是素数,小于100的合数一定有因子是2,3,5,7 有可能是素数因子就是本身,所以要增加4,9,25,49,来判断是否是合数 #includ
2016-06-09 16:23:22 301
原创 cf 680 B
链接:http://codeforces.com/contest/680/problem/B 题意:给你n个数字,你在a的位置,问你通过题给定的。。方法可以抓到多少个小偷//直接从a点开始向两边枚举#include using namespace std;int a[200];int main(){ int n,m; while(~s
2016-06-09 16:01:09 323
原创 cf 680 A
链接:http://codeforces.com/contest/680/problem/A 题意: 5个数字求删除2个相同或者3个相同之后剩下值之和的最小值//枚举每种情况找最小值#include using namespace std;int a[10];int main(){ int sum=0; for(int i=0;i<5;i++)
2016-06-09 15:57:52 299
原创 hdu 4565(矩阵快速幂)
So Easy!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3675 Accepted Submission(s): 1194Problem Description A sequence
2016-06-07 13:20:06 283
原创 hdu 4291(矩阵快速幂+循环节)
A Short problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2487 Accepted Submission(s): 876Problem Description Accor
2016-06-07 13:18:35 371
原创 hdu 5695(拓扑排序)
Gym ClassTime Limit: 6000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 866 Accepted Submission(s): 352Problem Description众所周知,度度熊喜欢各类体育
2016-06-07 13:16:17 334
原创 hdu 2256(矩阵快速幂)
Problem of PrecisionTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1226 Accepted Submission(s): 731Problem Description
2016-06-07 13:13:37 274
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人