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又掉了……但是没什么,比上一次好多了: ...
随机推荐
- IDEA中lombok插件的安装
1.在pom.xml中添加依赖 <dependency> <groupId>org.projectlombok</groupId> <artifactId&g ...
- connectTimeOut和readTimeout
网络编程时,经常遇到很多timeout异常,下面是java URLConnection 中经典的2种 timeout参数,这些参数设置不当的话,就会遇到timeout 异常. 1. ConnectTi ...
- Regularized least-squares classification(正则化最小二乘法分类器)取代SVM
在机器学习或者是模式识别其中有一种重要的分类器叫做:SVM .这个被广泛的应用于各个领域.可是其计算的复杂度以及训练的速度是制约其在实时的计算机应用的主要原因.因此也非常非常多的算法被提出来.如SMO ...
- 搭建企业内部DNS服务器,docker 部署内部 dnsmasq
获取镜像 docker pull jpillora/dnsmasq 配置域名 # http://oss.segetech.com/intra/srv/dnsmasq.conf #log all dns ...
- python—networkx:依据图的权重绘图
首先输入边和边的权重,随后画出节点位置.依据权重大小划分实边和虚边 #coding:utf-8 #!/usr/bin/env python """ An example ...
- 走入asp.net mvc不归路:[4]说说Action有哪些常见成员
一个控制器中,功能最终会落实到一个个Action中实现,最常见的是增删查改操作.这些Action是一个个的方法,一般返回值是ActionResult,并且是public 方法,可以带参数,可以添加元标 ...
- 服务器----1U、2U、3U、4U
U是一种表示服务器外部尺寸的单位,是unit的缩略语,详细的尺寸由作为业界团体的美国电子工业协会(EIA)所决定. 之所以要规定服务器的尺寸,是为了使服务器保持适当的尺寸以便放在铁质或铝质的机架上.机 ...
- LeetCode_3Sum Closest
一.题目 3Sum Closest Total Accepted: 32191 Total Submissions: 119262My Submissions Given an array S of ...
- zabbix基于SNMP 协议监控路由器
zabbix基于SNMP 协议监控路由器 步骤 步骤超级方便. 1. 路由器上开启snmp 2. 确保外网能訪问到 3. 用snmpwalk測试 4. 加入zabbix主机,SNMP interfac ...
- 解压Zip
import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import ja ...