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资格强调和遵循极其严格的职业操守和道德准则,世界各主要发 ...
随机推荐
- [转] Creating a Simple RESTful Web App with Node.js, Express, and MongoDB
You can find/fork the sample project on GitHub Hey! This and all my other tutorials will soon be mov ...
- Java基础知识强化之集合框架笔记34:List练习之集合的嵌套遍历
1. 需求: 我们班有学生,每一个学生是不是一个对象.所以我们可以使用一个集合表示我们班级的学生.ArrayList<Student> 但是呢,我们旁边是不是还有班级,每个班级是不是也是一 ...
- Oracle数据库管理员经常使用的表和视图
◆dba_开头 dba_users 数据库用户信息 dba_segments 表段信息 dba_extents 数据区信息 dba_objects 数据库对象信息 dba_tablespaces 数据 ...
- js 的post提交的写法
function AddEditDevice(data){ var form = $("#deviceEditform"); if (form.length == 0) { for ...
- HTML5 ArrayBufferView之DataView
DataView视图 如果一段数据包括多种类型(比如服务器传来的HTTP数据),这时除了建立ArrayBuffer对象的复合视图以外,还可以通过DataView视图进行操作. DataView视图提供 ...
- java判断字符串是否为空的方法总结
http://blog.csdn.net/qq799499343/article/details/8492672 以下是java 判断字符串是否为空的四种方法: 方法一: 最多人使用的一个方法, 直观 ...
- TSQL Beginners Challenge 3 - Find the Factorial
这是一个关于CTE的应用,这里我们用CTE实现阶乘 Factorial,首先来看一个简单的小实验,然后再来看题目.有的童鞋会问怎么没有2就来3了呢,惭愧,TSQL Beginners Challeng ...
- 怎样在官网上下载xcode7.2
其实我觉得还是有必要就这个写一篇论文的 以证明自己真的是个菜鸟 首先进入苹果开发者官网 https://developer.apple.com/ 选择 resource 然后 点击加号 然后下载就 ...
- java基础学习总结01
在过去的一周我们先学习了JAVA的一些基础知识和基础语法,基础知识包括:指令.程序.计算机语言.机器语言.高级语言的概念和特点,java的概念.平台.组建等,以及代码的编译过程,代码的开发流程.基础语 ...
- [LeetCode OJ] Best Time to Buy and Sell Stock I
Say you have an array for which the ith element is the price of a given stock on day i. If you were ...