codeforces round 422 div2 补题 CF 822 A-F

Posted 逐雪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces round 422 div2 补题 CF 822 A-F相关的知识,希望对你有一定的参考价值。

I‘m bored with life

水题

#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;
}

  

Crossword solving

水题

#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;
}

  

Hacker, pack your bags!

比较裸的线段树,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;
}

  

My pretty girl Noora

Liar

Madness

以上是关于codeforces round 422 div2 补题 CF 822 A-F的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round500-div2

Codeforces Round #422 B

Codeforces Round #422 (Div. 2)

Codeforces Round #326(Div2)

Codeforces Round #329 div2

Codeforces Round #328(Div2)