- 博客(128)
- 收藏
- 关注
原创 bzoj3357 [Usaco2004]等差数列
题目神奇dp,但是dp数组要用map存一下,好慢呀。。#include<bits/stdc++.h>#define N 2000 using namespace std;int n,A[N+5],ans;map <int,int> f[N+5];inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; retur
2017-09-28 22:50:56 258
原创 bzoj5043 密码破译
题目dp神题,公式什么的我们想出来,看一发题解吧。但是,这不是重点,重点是get到了一个新姿势。。int类型如果右移超过了32位,前32位是无效的,也就是说移40位和移8位是一样的233。因为这个,我样例都没过,好菜呀。#include<bits/stdc++.h>#define N 100000using namespace std;long long n,m,tmp;long long
2017-09-27 23:12:48 501
原创 bzoj4563 [Haoi2016]放棋子
题目感性认知,其实每行障碍的位置无所谓,不妨让它们在主对角线上,这样,就全错排就好了。公式:f[i]=(i-1)*(f[i-1]+f[i-2]),f[1]=0,f[2]=1.高精度。//全错排 f[1]=0,f[2]=1,f[i]=(i-1)(f[i-1]+f[i-2])#include<iostream>#include<cstdlib>#include<cstdio>#include<c
2017-09-27 23:09:15 232
原创 bzoj1572 [Usaco2009 Open]工作安排Job
题目震惊,stl都排到了第五,怕是膨胀了。。。简单题,贪心一下,先按时间排序,如果当前的时间大于了限制,取出堆中最小的即可。#include<bits/stdc++.h>#define N 100000 using namespace std;struct work{ int st; int rwd; bool operator < (const work &A)con
2017-09-27 23:06:49 311
原创 bzoj1617 [Usaco2008 Mar]River Crossing渡河问题
题目简简单单的dp。f[i]=min(f[i],f[j]+cost[j-i])+2*m答案为f[n]-m#include<bits/stdc++.h>using namespace std;int n,m;int cost[2505],f[2505];inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; ret
2017-09-27 23:06:34 266
原创 bzoj1699 [Usaco2007 Jan]Balanced Lineup排队
题目区间最小最大值,还不带修改,随意做吧,用ST表水过。。。#include<bits/stdc++.h>#define N 50000using namespace std;int n,q,l,r;int mx[N+5][25],mn[N+5][25];inline char nc(){ static char buf[100000],*p1=buf,*p2=buf;
2017-09-27 23:04:45 248
原创 bzoj4976 宝石镶嵌
题目如果没有k的限制的话,显然全部或起来最大啦。再想,k多小啊,如果n>=k+20,能有的都可以有,全部或起来就最大啦。不然,就简单dp一下。#include<bits/stdc++.h>#define N (1<<18)using namespace std;int n,k,ans;int A[N+5];int f[125][N+5];inline char nc(){ st
2017-09-26 23:01:41 242
原创 bzoj4291 [PA2015]Kieszonkowe
题目水题,几个变量就OK了。如果和为偶数,输出,否则减去最小奇数,输出。若答案为0,输出无解。#include<bits/stdc++.h>using namespace std;int n,x,tot;int mn;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(
2017-09-26 22:58:56 207
原创 2017.9.26 noip模拟赛 总结
呀,又有模拟赛了。先看一眼题,咦,第一题,一副什么数学公式之类的题的样子,不管了,先看后面。第二题:咦,难道不是tarjan缩点之后最小生成树吗,简单。写到后面发现,嗯,难道tarjan缩点后不就是树吗233。记录一下最小边就好了,但是,貌似被卡常数了。。第三题:咦,大概是鬼畜的数据结构题吧,好像RMQ N^2可以水60分,写吧。最后看题解,说什么他不知道有60分算法(笑哭最后第一题:n好小了,一副
2017-09-26 15:33:39 272 1
原创 bzoj3687 简单题
题目根据异或的性质可知,偶数个相同的数是没有影响的。之后就是简单dp了,但是,这道题可以用bitset这一神奇东西,当然得学习一下了。#include<bits/stdc++.h>#define N 2000010using namespace std;int n,x;long long ans;bitset <N> f;int main(){ freopen("in.txt"
2017-09-26 10:52:11 293
原创 bzoj2718 [Violet 4]毕业旅行
题目怕是一道ctsc原题。请参见这里#include<bits/stdc++.h>#define N 200using namespace std;int n,m,G[N+1][N+1],lk[N+1],x,y;int cnt;bool used[N+1];inline char nc(){ static char buf[100000],*p1=buf,*p2=buf;
2017-09-26 10:51:57 236
原创 bzoj1113 [Poi2008]海报PLA
题目首先,答案的上界显然就为n。之后考虑如何减少——如果两张海报高度相同,之间的海报都比它高,答案就减少一。单调队列就可以了。#include<bits/stdc++.h>#define N 250000using namespace std;int n,tot;int tmp,x;int stk[N+1],top; inline char nc(){ static char
2017-09-26 10:51:39 250
原创 bzoj2796 [Poi2012]Fibonacci Representation
题目感性认识,每次选最接近的斐波那契数就好了。记忆化一发。#include<bits/stdc++.h>using namespace std;int T;long long fib[105],n; map <long long,int> f;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return
2017-09-25 22:08:33 216
原创 bzoj2056 gift? 高精度?
题目高精度(滑稽我们发现,只有极限数据爆unsigned long long ,特判一下即可。#include<cstdio>using namespace std;int main(){ int T; scanf("%d",&T); while(T>0) { T--; unsigned long long a,b
2017-09-25 22:06:57 231
原创 bzoj1800 [Ahoi2009]fly 飞行棋
题目如果一条弧的长度为周长的一半,它肯定是直角(显然然后,前缀和维护一下就可以了。#include<bits/stdc++.h>#define N 100using namespace std;int n,tmp;int w[N+1];inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1=
2017-09-25 22:05:28 328
原创 bzoj3038 上帝造题的七分钟2
题目怕是道水题。线段树直接上,注意l可能大于r。如果区间最大值为1,就不操作了。其余暴力改就好了。#include<bits/stdc++.h>#define N 100000using namespace std;int n,m,l,r,opt; long long A[N+1],sum[N*4+1],mx[N*4+1];int ls[N*4+1],rs[N*4+1];inline c
2017-09-24 21:09:55 348
原创 bzoj2096 [Poi2010]Pilots
题目又是单调队列,好常见呀。维护最大与最小即可。#include<bits/stdc++.h>#define N 3000000using namespace std;int n,A[N+1],k,tmp,ans;int mx[N+1],mn[N+1];int lx,rx,ln,rn;inline char nc(){ static char buf[100000],*p1=b
2017-09-24 21:06:40 264
原创 bzoj2705 [SDOI2012]Longge的问题
题目简单题,狄利克雷卷积一下就好了。最开始我还以为线性筛就可以了。怕是失了智。#include<bits/stdc++.h>using namespace std;long long n,m,ans;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fr
2017-09-24 21:04:27 211
原创 bzoj2275 [Coci2010]HRPA
题目最多不超过两倍,我们想到了什么,对,斐波那契数列。详情请参见百度百科#include<bits/stdc++.h>long long n;long long f[60];int cnt; int main(){ freopen("in.txt","r",stdin); std::cin>>n; f[++cnt]=1;f[++cnt]=2; while(f
2017-09-24 21:02:24 387
原创 bzoj2717 [Violet 4]迷路的兔子
题目构造题。一共有C(n,2)对兔子,每天对三对兔子有影响,每对兔子不能超过三次。感性认识,能挺C(n,2)天。之后,就是如何构造了,当然需要玄学。#include<bits/stdc++.h>using namespace std;int n;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return
2017-09-24 20:59:33 448
原创 bzoj1370 [Baltic2003]Gang团伙
题目noip既视感。显然并查集。我们拆点,吧a拆成a与a’,如果是’F’的话,a与b连,否则,a与b’,a’与b。这样就好了。#include<bits/stdc++.h>#define N 5000 using namespace std;int m,n,x,y;int f[N+1],ans,tmp[N+1];char ch;inline char nc(){ static
2017-09-24 20:44:45 252
原创 bzoj2054 疯狂的馒头
题目区间操作,首选线段树,但是这道题显然不可行。怎么办,我们考虑如果从后往前的话,一个数最多被修改一次,并查集就派上用场了。看代码#include<bits/stdc++.h>#define N 10000000using namespace std;int n,m,p,q;int f[N+1],a[N+1];inline char nc(){ static char buf[1
2017-09-24 20:41:08 255
原创 bzoj2299 [HAOI2011]向量
题目浓浓的数学气息。参考裴蜀定理。百度百科#include<bits/stdc++.h>using namespace std;long long T,a,b,x,y,d;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000
2017-09-24 20:35:21 259
原创 bzoj3781 小B的询问
题目莫队第一题,照样先不理解,写板子。记板,记板。虽然不太典型,但也练练吧。思路最重要。//莫队算法 #include<bits/stdc++.h>#define N 50000using namespace std;struct que{ int l; int r; int block; int id; bool operator < (const
2017-09-23 23:59:20 158
原创 bzoj1600 [Usaco2008 Oct]建造栅栏
题目首先我们需要知道,四条边要构成四边形,必须每条边都小于周长的一半。之后就十分简单了。dp呀什么的都可以做了。记住结论。#include<bits/stdc++.h>using namespace std;int n,lim;int f[3000];int ans;int main(){// freopen("in.txt","r",stdin); cin>>n;
2017-09-23 23:57:43 221
原创 bzoj1601 [Usaco2008 Oct]灌水
题目构造一个虚拟点0,连向每一个点,边权为建造水站的费用,之后各个之间连边,跑最小生成树就OK了。#include<bits/stdc++.h>#define N 500using namespace std;int n,f[N+1],x,tot,ans,fx,fy;struct edge{ int x; int y; int val; bool operat
2017-09-23 23:54:56 167
原创 bzoj2296 【POJ Challenge】随机种子
题目构造题,首先,我们需要0~9都有,先构造9876543210*1000000,之后,让它整除x就好了,这也非常简单。#include<bits/stdc++.h>using namespace std;long long T,x;long long p=9876543210000000;inline char nc(){ static char buf[100000],*p1=
2017-09-23 23:52:47 251
原创 bzoj1342 [Baltic2007]Sound静音问题
题目显然是单调栈的裸题呀,就滑动窗口来更新,最大最小值,最后判断一下就好了。#include<bits/stdc++.h>#define N 1000000using namespace std;int n,A[N+1],m;int l,r,q[N+1],c;int mx[N+1],mn[N+1]; bool flag;inline char nc(){ static cha
2017-09-23 23:51:01 329
原创 bzoj1031 [JSOI2007]字符加密Cipher
题目算是bzoj上面的后缀数组第一题吧。比较简单。求出sa数组后输出s[sa[i]+len-1]即可。抓紧背板啊。。。#include<bits/stdc++.h>#define N 500000using namespace std;int sa[N+1],tmp1[N+1],tmp2[N+1],c[N+1];int m,n,len; char s[N+1];inline char n
2017-09-23 07:25:24 248 1
原创 bzoj1398 Vijos1382寻找主人 Necklace
题目最小表示法,模板。果然权限号板子多啊。背过吧2333#include<bits/stdc++.h>#define N 2000000using namespace std;char a[N+1],b[N+1];char c[N+1],d[N+1];int n,m1,m2;inline int get_M(char *tmp,int len){ int i=0,j=1,k=0
2017-09-22 23:03:25 241
原创 bzoj1121 [POI2008]激光发射器SZK
题目计算几何?不,不存在的。结论:答案为n/2。。感性认识,光路可逆,对吧233#include<bits/stdc++.h>using namespace std;int n; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,
2017-09-22 23:01:58 317
原创 bzoj2194 快速傅立叶之二
题目加强板子记忆。。。把b一反就成为板子了。//FFT 高精度乘法模板 #include<bits/stdc++.h>#define N 263075 using namespace std;int n,c[N],i,j,digit;complex<double> a[N],b[N],p[N];const double pi=acos(-1);void FFT(complex<doub
2017-09-22 22:59:54 181
原创 bzoj2179 FFT快速傅立叶
题目先写模板,再理解吧。FFT高精度乘法模板。//FFT 高精度乘法模板 #include<bits/stdc++.h>#define N 131075 using namespace std;int n,c[N],i,j;complex<double> a[N],b[N],p[N];const double pi=acos(-1);void FFT(complex<double> *
2017-09-22 22:58:22 164
原创 bzoj3298 [USACO 2011Open]cow checkers
题目先找规律,O(n)可过,但是,我们要更优。某玄学模拟赛威佐夫博弈。。#include<bits/stdc++.h>#define N 10000000using namespace std;int tmp;int T,x,y,m,n;int main(){// freopen("chess.in","r",stdin);// freopen("chess.out","w",s
2017-09-22 22:56:23 283
原创 bzoj3048 [Usaco2013 Jan]Cow Lineup
题目 怕又是一道单调栈的题。。。之前考过,过来A一发。#include<bits/stdc++.h>#include<set>using namespace std;long long l,r,ans,n,k,tot;map<long long,long long>mp;long long flag[100010],a[100010];long long q[100010];int
2017-09-22 22:53:20 211
原创 bzoj3101 N皇后
题目呀哈哈哈,我也成为氪金玩家了。。。开通了权限号,贼贵,不过,我们平均地想,一天也就不到1块钱(滑稽更要努力刷题了。考虑构造一波一、当n mod 6 != 2 或 n mod 6 != 3时,有一个解为: 2,4,6,8,…,n,1,3,5,7,…,n-1 (n为偶数) 2,4,6,8,…,n-1,1,3,5,7,…,n (n为奇数) (上面序列第i个数为ai,表示在第i行ai列放一个皇后;
2017-09-22 22:50:49 195
原创 bzoj4385 [POI2015]Wilcze doły
题目bzoj上的单调栈第一题,维护一个单调栈,让里面长度为d,再更新答案。#include<bits/stdc++.h>#define N 2000005using namespace std;long long n,p,d;long long A[N+1],st,ans; long long q[N+1],l,r;inline char nc(){ static char b
2017-09-22 22:46:43 294
原创 bzoj1179 [Apio2009]Atm
题目这题,咋一看,没什么思路。我们这样想,一个强连通分量中的点显然可以互相到达,所以就不需要考虑了,先缩点。然后重构图,跑一遍SPFA就好了,注意显然不会有环。#include<bits/stdc++.h>#define N 600000using namespace std;int n,m,A[N+1],x,y,s,p;int first[N+1],nxt[N+1],to[N+1],siz
2017-09-21 22:40:48 209
原创 2017.9.20 noip模拟赛 总结
模拟赛,不说什么了。时间不够(就做了2个多小时吧)。只写了两道题。。。第一题:又是矩阵乘法23。怕是今年第一题真是这个(flag。 比较简单,求f[i]=f[i-1]*x+i,x给定。 水过。第二题:想了十多分钟,然后茅塞顿开。。。就是求排第m/2的数(奇偶分开考虑),考虑二分答案为A,就求有几个(a[i]-a[j])<=A。即(a[i]<=a[j]+A),再枚举一下就好了。注意处理相等的情况。
2017-09-21 18:11:59 229
原创 codeforces 434 div2
算是正式的打了一次cf的题吧,之前都没有好好打过。(手动滑稽A:签到题吧,输入n,k,让n乘一个最小的数,使得末尾有k个0。我们知道,一个数末尾的0的个数,就是它2的因子数与5的因子数的最小值,这样,就可以轻松水过了。#include<bits/stdc++.h>using namespace std;long long n,k,m;long long num2,num5;long long
2017-09-18 13:59:21 407
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人