Codeforces round 440 div2 总结&&题解

A
答案显然,(A-1)/5+1
B
脑抽了
最大答案为2^33,以为会爆longlong写了python
写了就算了然后构造了数据去叉人。。。+1:-4
C
noip2010原题(导弹拦截)。,。。GTMDccf不卡特殊情况,,,粘板就WA啦
D
特判题。。注意T字形
E
莫队算法
首先得到前缀xor和
考虑[l,r]->[l,r+1],加入r+1,询问在r+1的前缀有多少个可以xor起来等于k
由于脑抽。。。调了40min终于过了样例,1:59:54交然后没交上去。。。
虽然交上去会WA5而且第八个点没开ll
自己弱。。。

(这么容易AK的一场被玩成这样。。。打完B,C都挂了

A

int main(){
	//freopen("xxx.in","r",stdin);
	//freopen("xxx.out","w",stdout);
	int a;cin>>a;
	cout<<(a-1)/5+1;
}
B
_tot=-1;
_in_splay=[]
def init():
    global _tot
    global _in_splay
    _tot=-1
    _in_splay=[int(i) for i in raw_input().split()]
  
def splay():
    global _tot
    _tot=_tot+1
    return _in_splay[_tot]
  
  
'''main'''
a=[]
n=input()
if n==1:
    t=input()
    if t==1:
        print 1
    else:
        print 0
    exit()
init()
l=1
r=n
a.append(0)
for x in range(1,n+1):
    a.append(splay())
a.append(0)
a.append(0)
while a[l]==0:
    l=l+1
    if l==n:
        print 0
        exit()
while a[r]==0:
    r=r-1
if l==r:
    print 1
    exit()
ans=1
tot=1
for i in range(l,r+1):
    if a[i]==1:
        ans=ans*tot;
        tot=1
    else:tot=tot+1
print ans
C

#define ll long long
#define F first
#define S second
pair<ll,ll> d[2003];
ll n,i,h1,h2,k1,k2,x,y;
ll ans,m2;
ll dist(ll a,ll b,ll c,ll d){
	return (a-c)*(a-c)+(b-d)*(b-d);
}
Int main(){
	cin>>n>>h1>>k1>>h2>>k2;
	for(i=0;i<n;i++) {
		splay(x),splay(y);
		d[i].F=dist(h1,k1,x,y);
		d[i].S=dist(h2,k2,x,y);
	}
	sort(d,d+n);
	ans=d[n-1].first;m2=0;
	for(i=n-1;i>=0;i--) {
		m2=max(m2,d[i].second);
		ans=min(ans,m2+(i?d[i-1].first:0));
	}
	cout<<ans;
}

D

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
#define ll long long
#define mod 1000000007ll
#define inf 1050000000ll
using namespace std;
void init(){
	splay(a),splay(b),splay(c),splay(d),splay(e),splay(f);
}

void dfff(){
	if((a==c&&c==e)||(b==d&&d==f))puts("1");
	else if(a==c)if(f>=max(b,d)||f<=min(b,d))puts("2");else puts("3");
	else if(a==e)if(d>=max(b,f)||d<=min(b,f))puts("2");else puts("3");
	else if(c==e)if(b>=max(f,d)||b<=min(f,d))puts("2");else puts("3");
	else if(b==d)if(e>=max(a,c)||e<=min(a,c))puts("2");else puts("3");
	else if(b==f)if(c>=max(a,e)||c<=min(a,e))puts("2");else puts("3");
	else if(d==f)if(a>=max(e,c)||a<=min(e,c))puts("2");else puts("3");
	else puts("3");
}
int main(){
	init();dfff();
	
	return 0;
}

E

struct Q{
	int l,r,id,ans;
}q[100010];
int Ans[100010];
const int P=300;
bool comp(const Q &a,const Q &b){
	if(a.l/P!=b.l/P)return a.l/P<b.l/P;
	return a.r<b.r;
}
int s[2000010];
int t[2000010];
int l=2,r=1,ans=0,n,m,k;
int a[100010];
Int main(){
	freopen("xxx.in","r",stdin);
	freopen("xxx.out","w",stdout);
	splay(n),splay(m),splay(k);
	for(int i=2;i<=n+1;i++){
		splay(a[i]);a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++){
		splay(q[i].l),splay(q[i].r);
		q[i].l++,q[i].r++;
		q[i].id=i;
	}
	sort(q+1,q+m+1,comp);
	s[0]=1;
	for(int i=1;i<=m;i++){
		while(r<q[i].r){
			ans+=s[a[r+1]^k];
			s[a[++r]]++;
		}
		while(r>q[i].r){
			s[a[r]]--;
			ans-=s[a[r]^k];
			r--;
		}
		while(l<q[i].l){
			s[a[l-1]]--;
			ans-=s[a[l-1]^k];
			s[a[l-1]]++;
			s[a[l-1]]--;l++;
		}
		while(l>q[i].l){
			ans+=s[a[l-2]^k];
			s[a[(--l)-1]]++;
		}
		Ans[q[i].id]=ans;
	}

	for(int i=1;i<=m;i++){
		printf("%I64d\n",Ans[i]);
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值