20260103 模拟赛记

course

傻逼题目描述,读炸了,在调试的时候才读懂题,傻逼完了。

100 pts。

sequence

简单题,但是我把其中一个 \(n\) 写成了 \(n - 1\)\(100 \to 25\),警钟长鸣。

25 pts。

divisors

先考虑 \(40\):因为 \(n\) 比较小,所以对每个 \(i\)\(O(m)\) 的时间算有几个 \(a_i\) 是其倍数即可,\(O(nm)\)

再想到 \(60\):直接做,因为只有一个数,所以 \(k = 0\) 的答案是 \(n - d(a_1)\)\(k = 1\) 的答案是 \(d(a_1)\) 即可。

最后想到满分:对每个 \(a_i\) 算其因数,我们只需要小于等于 \(n\) 的因数就可以,然后开个桶,记每个因数出现的次数,显然只有这些因数可以贡献答案。当 \(k = i\) 时,我们只要找出现次数为 \(i\) 的因数的个数即可,特别的,\(k = 0\) 的答案是 \(n\) 减去所有因数的种类数。

这样就做完了。

100 pts。

market

不会。用背包直接做可以得到 \(60\)

60 pts。

总结

理论应当得分 \(100 + 100 + 100 + 60 = 360\),实际上挂了一题所以 \(100 + 25 + 100 + 60 = 285\),菜完了。

赛时代码:

course.cpp :

#include<bits/stdc++.h>
#define ll long long
#define db double
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define mkp make_pair
#define il inline
#define endl "\n"
using namespace std;
const ll mod=998244353;
const ll inf=1e18;
ll n,M[20],K[20],ans=0,tong[105];pll a[20][5][5];
ll ha(ll x,ll y){
	return x*10+y;
}
void dfs(ll k,ll sum){
	if(k>n){
		ans=max(ans,sum);
		return ;
	}
	for(ll i=1;i<=M[k];i++){
		ll p=0;bool f=0;
		for(ll j=1;j<=K[k];j++){
			if(tong[ha(a[k][i][j].first,a[k][i][j].second)]){
				f=1;break;
			}
		} 
		if(f) continue;
		for(ll j=1;j<=K[k];j++){
			p++,tong[ha(a[k][i][j].first,a[k][i][j].second)]++;
		}
		dfs(k+1,sum+p);
		for(ll j=1;j<=K[k];j++){
			tong[ha(a[k][i][j].first,a[k][i][j].second)]--;
		}
	}
	dfs(k+1,sum);
}
int main(){
	freopen("course.in","r",stdin);
	freopen("course.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll m,k;cin>>m>>k;
		M[i]=m,K[i]=k;
		for(ll j=1;j<=m;j++){
			for(ll p=1;p<=k;p++){
				cin>>a[i][j][p].first>>a[i][j][p].second;
			}
		}
	}
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}
/*
4
1 1 2 1
2 1 2 1 3 1
2 2 3 1 4 2 4 2 5 2
2 2 3 2 4 2 5 2 5 3

1 1
4 4
3 1
4 1
2 2
1 3
1 1
1 1
2 3
5 3
3 5
5 1
4 1
1 1
1 1
5 1

*/

sequence.cpp :

#include<bits/stdc++.h>
#define ll long long
#define db double
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define mkp make_pair
#define il inline
#define endl "\n"
using namespace std;
const ll mod=998244353;
const ll inf=1e18;
ll n,a[200005],dp[200005],L[200005],ans=0;
int main(){
	freopen("sequence.in","r",stdin);
	freopen("sequence.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(ll i=1;i<=n;i++) cin>>a[i];
	for(ll i=1;i<=n;i++) dp[a[i]]=dp[a[i]-1]+1,L[i]=dp[a[i]];
	for(ll i=1;i<=n;i++) dp[i]=0;
	for(ll i=n-1;i;i--){
		dp[a[i]]=dp[a[i]-1]+1;
		ll l=L[i]-1,r=dp[a[i]]-1;
		if(l>=2*r) ans=max(ans,3*r+1);
		else ans=max(ans,l/3*2+1);
	}
	cout<<ans<<endl;
	return 0;
}

divisors.cpp :

#include<bits/stdc++.h>
#define ll long long
#define db double
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define mkp make_pair
#define il inline
#define endl "\n"
using namespace std;
const ll mod=998244353;
const ll inf=1e18;
ll n,m,a[205],ans[100005];vec<ll> D[100005];map<ll,ll> mp;
ll d(ll x){
	ll p=0;
	for(ll i=1;i*i<=x;i++){
		if(x%i==0&&i*i!=x){
			if(i<=n) p++;
			if(x/i<=n) p++;
		}else{
			if(x%i==0&&i<=n) p++;
		}
	}
	return p;
}
void wwqwq(ll x,ll p){
	for(ll i=1;i*i<=x;i++){
		if(x%i==0&&i*i!=x){
			if(i<=n) D[p].pb(i);
			if(x/i<=n) D[p].pb(x/i);
		}else{
			if(x%i==0&&i<=n) D[p].pb(i);
		}
	}
}
int main(){
	freopen("divisors.in","r",stdin);
	freopen("divisors.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(ll i=1;i<=m;i++) cin>>a[i];
	if(n<=100000){
		for(ll i=1;i<=n;i++){
			ll p=0;
			for(ll j=1;j<=m;j++){
				if(a[j]%i==0) p++;
			}
			ans[p]++;
		}
		for(ll i=0;i<=m;i++) cout<<ans[i]<<endl;
	}else if(m==1){
		cout<<n-d(a[1])<<endl;
		cout<<d(a[1])<<endl;
	}else{
		set<ll> st;
		for(ll i=1;i<=m;i++) wwqwq(a[i],i);
		for(ll i=1;i<=m;i++){
			for(auto p:D[i]) mp[p]++,st.insert(p);
		}
		for(auto p:st){
//			cout<<p<<" "<<mp[p]<<endl;
			ans[mp[p]]++;
		}
		cout<<n-st.size()<<endl; 
		for(ll i=1;i<=m;i++){
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}

market.cpp :

#include<bits/stdc++.h>
#define ll long long
#define db double
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define mkp make_pair
#define il inline
#define endl "\n"
using namespace std;
const ll mod=998244353;
const ll inf=1e18;
ll n,m,ask[100005],f[305];
struct shop{
	ll c,v,t;
	friend bool operator<(shop x,shop y){
		return x.t<y.t;
	}
}p[305];
struct node{
	ll t,M,id;
	friend bool operator<(node x,node y){
		return x.t<y.t; 
	} 
}a[100005];
ll Find(ll x){
	ll l=1,r=n,ans=0;
	while(l<=r){
		ll md=(l+r)>>1;
		if(p[md].t<=x){
			l=md+1,ans=md;
		}else{
			r=md-1;
		}
	}
	return ans;
}
int main(){
	freopen("market.in","r",stdin);
	freopen("market.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		cin>>p[i].c>>p[i].v>>p[i].t;
	}
	sort(p+1,p+n+1);
	for(ll i=1;i<=m;i++){
		cin>>a[i].t>>a[i].M,a[i].id=i;
	}
	sort(a+1,a+m+1);
	for(ll i=1;i<=m;i++){
		ll P=Find(a[i].t);
		if(!P) ask[a[i].id]=0;
		else{
			for(ll j=0;j<=a[i].M;j++) f[j]=-1e9;
			f[0]=0;ll ans=-1e9;
			for(ll k=1;k<=P;k++){
				for(ll j=a[i].M;j>=p[k].c;j--){
					f[j]=max(f[j],f[j-p[k].c]+p[k].v);
				}
			}
			for(ll j=0;j<=a[i].M;j++) ans=max(ans,f[j]);
			ask[a[i].id]=ans;
		}
	}
	for(ll i=1;i<=m;i++) cout<<ask[i]<<endl;  
	return 0;
}
/*
5 2
5 5 4
1 3 1
3 4 3
6 2 2
4 3 2
3 8
5 9

1 3 1
4 3 2 
6 2 2
3 4 3
5 5 4
*/
posted @ 2026-01-03 13:50  Laiyiwen_01  阅读(16)  评论(1)    收藏  举报