跳到正文

生活·游记

CSP-S 2025游记

cyq32ent约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年11月9日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 2 分钟

版本

  1. v1当前

同一机房的大神 T4 写的 88 分暴力没有编译导致 CE,于是我怀着对考试结束前5分钟测了小样例的庆幸打开了我的 T4 暴力代码。

C++
//employ.cpp
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int n,m,s[505],c[505];
const int mod=998244353;
int main(){
//	freopen("employ.in","r",stdin);
//	freopen("employ.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){char f;
	cin>>f;s[i]=f-'0';
	}long long fac=1;
	for(int i=1;i<=n;i++)fac=fac*i%mod;
	for(int i=1;i<=n;i++)cin>>c[i];
	if(n<=10){
		vector<int>V;int ans=0;
		for(int i=1;i<=n;i++)V.push_back(i);
		for(int i=1;i<=fac;i++){
			int num=0,fu=0,j=1;
			for(int i:V){
				if(fu>=c[i]||!s[j])fu++;
				else num++;
				j++;
			}if(num>=m)ans++;
			next_permutation(V.begin(),V.end());
		}printf("%d",ans);
	}
	else printf("%lld",fac);
}

//freopen。

听说 7 钩线大约191。没了这 8 分刚好没上。

原文