codeforces round 422 div2 补题 CF 822 A-F
水题
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=1,M=1,MOD=1; int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
LL a,b;
scanf("%I64d%I64d",&a,&b);
LL c=min(a,b);
LL ans=1;
for(LL i=2;i<=c;i++)
ans=ans*i;
printf("%I64d\n",ans);
return 0;
}
水题
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=1,M=1,MOD=1; int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
int n,m;
char a[2000],b[2000];
scanf("%d%d",&n,&m);
scanf("%s%s",&b,&a);
vector<int>pos;
pos.resize(n+1);
for(int i=0;i+n-1<m;i++)
{
vector<int>pon;
for(int j=0;j<n;j++)
{
if(a[i+j]!=b[j])pon.push_back(j+1);
}
if(pon.size()<pos.size())pos=pon;
}
printf("%d\n",pos.size());
for(int i=0;i<pos.size();i++)
{
printf("%d ",pos[i]);
}
printf("\n");
return 0;
}
比较裸的线段树,Mdzz 一开始没用LL WA了好几发 线段树写的还不是很熟练。。 最后调出来没时间看后边的题了!!
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=200005,M=15000000,MOD=1;
LL L[N],R[N],C[N];
int rt1[N],rt2[N],lc[M],rc[M],sumc[M],tot;
int n,x;
void update(int cur)
{
sumc[cur]=2e9+10;
if(lc[cur]!=0)sumc[cur]=min(sumc[cur],sumc[lc[cur]]);
if(rc[cur]!=0)sumc[cur]=min(sumc[cur],sumc[rc[cur]]);
}
void insert(int cur,int val,int cost,int l,int r)
{
if(l==r&&l==val){if(sumc[cur]==0)sumc[cur]=cost;else sumc[cur]=min(sumc[cur],cost);return ;}
int mid=(l+r)/2;
if(val<=mid)
{
if(lc[cur]==0)lc[cur]=++tot;
insert(lc[cur],val,cost,l,mid);
}
else
{
if(rc[cur]==0)rc[cur]=++tot;
insert(rc[cur],val,cost,mid+1,r);
}
update(cur);
}
LL que1(int cur,int vl,int vr,int l,int r)
{
if(cur==0||r<vl||l>vr)return 2e9+10;
if(r<=vr&&l>=vl)return sumc[cur];
int mid=(l+r)/2;
LL ret=2e9+10;
if(vl<=mid)ret=min(ret, que1(lc[cur],vl,min(mid,vr),l,mid));
if(vr>mid) ret=min( ret,que1(rc[cur],max(vl,mid+1),vr,mid+1,r));
return ret;
}
int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
scanf("%d%d",&n,&x);
for(int i=1;i<=n;i++)
{
scanf("%I64d%I64d%I64d",&L[i],&R[i],&C[i]);
int len=R[i]-L[i]+1;
if(rt1[len]==0&&rt2[len]==0)rt1[len]=++tot,rt2[len]=++tot;
insert(rt1[len],R[i],C[i],1,N);insert(rt2[len],L[i],C[i],1,N);
}
LL ans=2e9+10;
for(int i=1;i<=n;i++)
{
int len=R[i]-L[i]+1;
if(len>=x)continue;
ans=min(ans,C[i]+min(que1(rt1[x-len],1,L[i]-1,1,N),que1(rt2[x-len],R[i]+1,N,1,N)));
}
if(ans==2e9+10)printf("-1\n");
else printf("%I64d\n",ans);
return 0;
}
E Liar
F Madness
codeforces round 422 div2 补题 CF 822 A-F的更多相关文章
- codeforces round 421 div2 补题 CF 820 A-E
A Mister B and Book Reading O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...
- Codeforces round 419 div2 补题 CF 816 A-E
A Karen and Morning 水题 注意进位即可 #include<bits/stdc++.h> using namespace std; typedef long long i ...
- codeforces round 418 div2 补题 CF 814 A-E
A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...
- codeforces round 417 div2 补题 CF 812 A-E
A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; i ...
- codeforces round 416 div2 补题 CF 811 A B C D E
A. Vladik and Courtesy 水题略过 #include<cstdio> #include<cstdlib> #include<cmath> usi ...
- codeforces round 420 div2 补题 CF 821 A-E
A Okabe and Future Gadget Laboratory 暴力 #include<bits/stdc++.h> using namespace std; typedef l ...
- Educational Codeforces Round 23 A-F 补题
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...
- codeforces 447 A-E div2 补题
A DZY Loves Hash 水题 #include<iostream> #include<cstdio> #include<cstdlib> #include ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
随机推荐
- Executors
提供了工厂方法: Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, Thread ...
- P1576 最小花费 洛谷
https://www.luogu.org/problem/show?pid=1576 题目背景 题目描述 在n个人中,某些人的银行账号之间可以互相转账.这些人之间转账的手续费各不相同.给定这些人之间 ...
- 嵌入式cpu架构
原文:http://www.kaixin001.com/repaste/11007221_7220618944.html### 内容: 目前主要CPU架构有ARM.X86/Atom.MIPS.Powe ...
- Netty入门教程:Netty拆包粘包技术讲解
Netty编解码技术是什么意思呢?所谓的编解码技术,说白了就是java序列化技术.序列化有两个目的: 1.进行网络传输2.对象持久化 虽然我们可以使用java进行序列化,Netty去传输.但是java ...
- Java程序的编译过程?由.java 到.class的过程?
Javac是一种编译器,它的任务就是将Java源代码语言转化为JVM能够识别的一种语言,然后由JVM将JVM语言再转化成当前这个机器能够识别的机器语言 词法分析器:读取源代码,一个字节一个自己的读取出 ...
- PostgreSQL SystemTap on Linux
http://digoal126.wap.blog.163.com/w2/blogDetail.do;jsessionid=3949B03DE151DA0E55D807466C5E630B.yqblo ...
- win7安装ANT
点击进入ant官网,找到下载选项. 选择下载安装文件.其余的源文件和手册的下载步骤完全相同. 可以下载官网上对应系统的最新版本.也可以在old ant 版本中选择自己需要的版本.笔者需要ant ...
- 文件重定向,getline()获取一样,屏幕输出流,格式控制符dec,oct,hex,精度控制setprecision(int num),设置填充,cout.width和file(字符),进制输入
1.在window下的命令重定向输出到文件里 2.将内容输入到某个文件里的方式:命令<1.txt (使用1.txt中的命令) 3.读取文件里的名,然后将命令读取最后输出到文件里.命令< ...
- CSS样式布局入门介绍,非常详尽
转载自:http://wenboxz.com/archives/try-css-layout.html/
- 使用外部 toolchain 编译 openwrt
默认编译 openwrt 时会先编译一套 toolchain. 这个步骤耗时较长. 使用外部 toolchain 可以多个 project 共用一套 toolchain , 而且也不重再编译它了. 省 ...