ABC278

Shift

不讲

Misjudge the Time

不讲

FF

用map做

#include <bits/stdc++.h>
using namespace std;
int N,Q;
int main() {
	cin >> N >> Q;
    set<pair<int,int> > follows;
    for (int i=1;i<=Q;i++) {
        int type, A, B;
        cin>>type>>A>>B;
        if (type==1)
            follows.insert(make_pair(A, B) );
        else if (type==2)
            follows.erase({A, B});
        else
            cout << (follows.count({A, B}) && follows.count({B, A}) ? "Yes" : "No") << endl;
    }
    return 0;
}

D - All Assign Point Add

模拟

#include<bits/stdc++.h>
using namespace std;
int n,q,t,x,y,s;
map<int,long long> a;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>t;
		if(t==3){
			cin>>x;
			if(a[x]==0)
				a[x]+=s;
			cout<<a[x]<<endl;
		}
		if(t==1){
			cin>>x;
			a.clear();
			s=x;
		}
		if(t==2){
			cin>>x>>y;
			if(a[x]==0)
				a[x]+=s;
			a[x]+=y;
		}
	}
	return 0;
}

E - Grid Filling

暴力

#include<bits/stdc++.h>
using namespace std;
int H,W,n,h,w,a[310][310],sum[310],summ[310],ans;
int main(){
	cin>>H>>W>>n>>h>>w;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++){
			cin>>a[i][j];
			sum[a[i][j]]++;
			summ[a[i][j]]++;
		}
	for(int i=1;i<=H-h+1;i++){
		for(int j=1;j<=n;j++)
			sum[j]=summ[j];
		for(int k=i;k<=i+h-1;k++)
			for(int j=1;j<=w;j++)
				sum[a[k][j]]--;
		ans=0;
		for(int l=1;l<=n;l++)
			if(sum[l]>0)
				ans++;
		cout<<ans;
		for(int j=2;j<=W-w+1;j++){
			for(int k=i;k<=i+h-1;k++){
				sum[a[k][j-1]]++,sum[a[k][j+w-1]]--;
			}
				
			ans=0;
			for(int l=1;l<=n;l++)
				if(sum[l]>0)
					ans++;	
			cout<<" "<<ans;
		}
		cout<<endl;
	}
	return 0;
}

F - Shiritori

看数据范围n<=16,很明显是状压。下一个选什么只和已经选了哪些以及上一个选的最后一个字母有关。26*(2^16)=170万。然后来分析,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值