Luogu 考前模拟Round. 1
A.情书
题目:http://www.luogu.org/problem/show?pid=2264
赛中:sb题,直接暴力匹配就行了,注意一下读入和最后一句话的分句
赛后:卧槽 怎么只有40
B.小朋友的球
题目:http://www.luogu.org/problem/show?pid=1655
赛中:sb题,第二类斯特林数,加个高精度就行了,我还写了个暴力对拍
赛后:卧槽 怎么只有80 未知错误怎么回事儿啊
C.命运的彼方
题目:http://www.luogu.org/problem/show?pid=2263
赛中:sb题,poi2008砖块,splay维护中位数,加减数即可,数据范围有点大,算一下好像也能过?
赛后:卧槽 怎么CE了 又交了4、5遍 怎么还是CE bzoj还能A啊
1.5h交完3t,然后坐等AK。。。
最后知道真相的我眼泪掉下来。。。
我已无力吐槽luogu。。。
3道sb题,结果一半分都没有,是我太sb还是我太sb。。。
明信片再见。。。
UPD:t2 数据出错
t3 long long 的常数需要在后面加 ll 。。。
luogu为何连CE都不报,以后还能不能快乐地做比赛了T_T
UPD:还是贴上代码吧。。。
A
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 500+100
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
string a[],b[];
inline bool find(int x,int y)
{
int l1=a[x].length(),l2=b[y].length();
for0(i,l2-l1)
{
int j=i,k=;
while(a[x][k]==b[y][j])k++,j++;
if(k<l1-)continue;
return ;
}
return ;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n=read();
for1(i,n+)
{
getline(cin,a[i]);
int l=a[i].length();
for0(j,l-)if(a[i][j]>='A'&&a[i][j]<='Z')a[i][j]+='a'-'A';
}
int m=;
for0(i,a[n+].length()-)
{
if(a[n+][i]=='.')m++;
b[m]=b[m]+a[n+][i];
}
m--;
int ans=;
for1(i,n)
for1(j,m)
if(find(i,j))ans++;
printf("%d\n",ans);
return ;
}
B
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 500
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 10000
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
class bigg
{
public:
int num[maxn],len;
bigg(){memset(num,,sizeof(num));len=;}
bigg operator =(const bigg &b)
{
memset(num,,sizeof(num));
len=b.len;
for1(i,len)num[i]=b.num[i];
return (*this);
}
bigg operator =(int b)
{
memset(num,,sizeof(num));len=;
while(b)num[++len]=b%mod,b/=mod;
return (*this);
}
bigg operator *(int b)
{
bigg ans;
ans.len=len;
for1(i,len)ans.num[i]=num[i];
int x=;
for1(i,len)
{
x+=ans.num[i]*b;
ans.num[i]=x%mod;
x/=mod;
}
if(x)ans.num[++ans.len]=x;
return ans;
}
bigg operator +(const bigg &b)
{
bigg ans;ans=;
ans.len=max(len,b.len);
for1(i,ans.len)
{
ans.num[i]+=num[i]+b.num[i];
ans.num[i+]=ans.num[i]/mod;
ans.num[i]%=mod;
}
if(ans.num[ans.len+])ans.len++;
return ans;
}
void print()
{
printf("%d",num[len]);
for3(i,len-,)printf("%04d",num[i]);printf("\n");
}
};
bigg f[][];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
for1(i,)f[i][]=;
for2(i,,)
for2(j,,i)
f[i][j]=f[i-][j]*j+f[i-][j-];
int n,m;
while(cin>>n>>m)f[n][m].print();
return ;
}
C
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000000000ll
#define maxn 1500000
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define for2(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int fa[maxn],c[maxn][],n,k,tot=,rt=;
ll sum[maxn],s[maxn],v[maxn],a[maxn];
inline void pushup(int x)
{
int l=c[x][],r=c[x][];
s[x]=s[l]+s[r]+;
sum[x]=sum[l]+sum[r]+v[x];
}
inline void rotate(int x,int &k)
{
int y=fa[x],z=fa[y],l=c[y][]==x,r=l^;
if(y==k)k=x;else c[z][c[z][]==y]=x;
fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
c[y][l]=c[x][r];c[x][r]=y;
pushup(y);pushup(x);
}
inline void splay(int x,int &k)
{
while(x!=k)
{
int y=fa[x],z=fa[y];
if(y!=k)
{
if(c[z][]==y^c[y][]==x)rotate(x,k);else rotate(y,k);
}
rotate(x,k);
}
}
inline void ins(int &k,int kk,ll x)
{
if(!k)
{
k=++tot;s[tot]=;fa[tot]=kk;v[tot]=sum[tot]=x;return;
}
s[k]++;
if(x<=v[k])ins(c[k][],k,x);else ins(c[k][],k,x);
pushup(k);
}
inline int find(int k,int x)
{
int l=c[k][],r=c[k][];
if(s[l]+==x)return k;
else if(s[l]>=x)return find(l,x);
else return find(r,x-s[l]-);
}
inline int pos(int k,ll val)
{
if(v[k]==val)return k;
else if(val<v[k])return pos(c[k][],val);
else return pos(c[k][],val);
}
inline void del(ll val)
{
splay(pos(rt,val),rt);
int x=c[rt][],y=c[rt][];
while(c[x][])x=c[x][];
while(c[y][])y=c[y][];
splay(x,rt);splay(y,c[x][]);
fa[c[y][]]=c[y][]=;
pushup(y);pushup(x);
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=read();k=read();
for1(i,n)a[i]=read();
ins(rt,,-);ins(rt,,1000000000001ll);
for1(i,k-)ins(rt,,a[i]),splay(i+,rt);
ll ans=inf,x,y;
for1(i,n-k+)
{
ins(rt,,a[i+k-]);splay(i+k+,rt);
x=find(rt,(s[rt]>>)+);y=v[x];
splay(x,rt);
ans=min(ans,s[c[x][]]*y-sum[c[x][]]+sum[c[x][]]-s[c[x][]]*y);
del(a[i]);
if(ans==1000000000002ll)break;
}
cout<<ans-1000000000002ll<<endl;
return ;
}
Luogu 考前模拟Round. 1的更多相关文章
- 2019.11.9 csp-s 考前模拟
2019.11.9 csp-s 考前模拟 是自闭少女lz /lb(泪奔 T1 我可能(呸,一定是唯一一个把这个题写炸了的人 题外话: 我可能是一个面向数据编程选手 作为一个唯一一个写炸T1的人,成功通 ...
- 2017.11.8 Noip2017 考前模拟赛
----------------------------------T1---------------------------------- ——>足球联赛 题目描述 巴蜀中学新一季的足球联赛开 ...
- 2017.11.7 Noip2017 考前模拟赛
----------------------------------T1---------------------------------- ——>数学老师的报复 题目描述 11 班数学大佬 Y ...
- 【NOIP考前模拟赛】纯数学方法推导——旅行者问题
一.写在前面 这题似乎是一道原创题目(不是博主原创),所以并不能在任何OJ上评测,博主在网盘上上传了数据(网盘地址:http://pan.baidu.com/s/1mibdMXi),诸位看官需者自取. ...
- 【XJOI】【NOI考前模拟赛7】
DP+卡常数+高精度/ 计算几何+二分+判区间交/ 凸包 首先感谢徐老师的慷慨,让蒟蒻有幸膜拜了学军的神题.祝NOI2015圆满成功 同时膜拜碾压了蒟蒻的众神QAQ 填填填 我的DP比较逗比……( ...
- 16.1116 NOIP 考前模拟(信心题)
分火腿 (hdogs.pas/.c/.cpp) 时间限制:1s:内存限制 64MB 题目描述: 小月言要过四岁生日了,她的妈妈为她准备了n根火腿,她想将这些火腿均分给m位小朋友,所以她可能需要切火腿. ...
- 2019/8/27 Test(luogu 五月天模拟赛)
\(2019/8/27\)大考 \(\color{#ff0808}{\text{初二诀别赛(SAD)}}\) 题目名称 链接 寿司 \(BSOJ5111\) 秀秀的森林 \(BSOJ5125\) 分组 ...
- CTSC2015&APIO2015滚粗记
CTSC 这次CTSC的考试,觉得还是考出了自己该有的水平.虽然自己最后还是没有得到金牌,但是我觉得自己尽力了,也没有什么太大的遗憾.比起省选,自己在应试的方面又有了很大的进步. Day1是我主要捞分 ...
- 考了3年,工作四年,零基础在职终于拿到CFA证书
大家都知道CFA Charterholder是独有的全球公认的投资管理从业人员高职业水平和道德水准的有力证明,是金融界卓越专业成就的象征:CFA资格强调和遵循极其严格的职业操守和道德准则,世界各主要发 ...
随机推荐
- Web的鼠标拖动效果
以前写过一个拖动效果的Demo,拖拽元素新位置的计算是放在拖拽元素的mousemove事件中进行的.计算效率差,而且效果不好.所以一直有想怎样才能做出jquery-ui那种顺滑的拖拽效果. 其实顺滑的 ...
- list-style无颜色问题解决,list-style-type无颜色解决
list-style无颜色问题解决,list-style-type无颜色解决 >>>>>>>>>>>>>>>& ...
- 洛谷比赛 堕落的Joe
/*暴力50*/ #include<iostream> #include<cstdio> #include<cstring> #define maxn 100010 ...
- display:table- cell属性的练习
display:table- cell属性指让标签元素以表格单元格的形式呈现,类似于td标签.目前IE8+以及其他现代浏览器都是支持此属性的,但是IE6/7只能对你说 sorry了,这一事实也是大大制 ...
- dnw for linux: Ubuntu下可用,无需编译驱动,mini2440可用
1.安装所需库文件 sudo apt-get install libusb-dev 2.源代码如下 /* dnw2 linux main file. This depends on libusb. * ...
- Zend Server安装后首次运行就出现Internal Server Error的解决
无论是使用哪个版本的Zend Server来搭建PHP服务器,首次运行都会出现Internal Server Error的错误,对很多新手而言,每当看到这种错误时,那一刻内心绝对都是崩溃的.然而,这个 ...
- [转]Windows中的命令行提示符里的Start命令执行路径包含空格时的问题
转自:http://www.x2009.net/articles/windows-command-line-prompt-start-path-space.html 当使用Windows 中的命令行提 ...
- jQuery慢慢啃之属性(三)
1.attr(name|properties|key,value|fn)设置或返回被选元素的属性值. $("img").attr("src");//获取属性 $ ...
- jsp注释方式
1,HTML的注释方法 <!--...add your comments here...--> 说明:使用该注释方法,其中的注释内容在客户端浏览中是看不见的.但是查看源代码时,客户是可以看 ...
- import uno 错误
安装aeroolib 模块后,提示没有 uno 相关段一些模块, 原因是这些模块是 openoffice 中段,需要先安装 openoffice. 1:清除所有 libreoffice 软件, su ...