站外题代码为什么报错QAQ
  • 板块学术版
  • 楼主__ycy1124__
  • 当前回复8
  • 已保存回复8
  • 发布时间2024/10/4 08:28
  • 上次更新2024/10/4 10:28:21
查看原帖
站外题代码为什么报错QAQ
1287433
__ycy1124__楼主2024/10/4 08:28

蒟蒻太菜,低级错误勿喷,编译错误[Error] 'getchar_unlocked' was not declared in this scope

#include<bits/stdc++.h>
#define int long long
#define md 998244353
#define Maxn 1000001
#define Maxw 51
#define base 13333331
std::unordered_map<int,int>mymap;
using namespace std;
void read(int &x){
	x=0;
	char ch=getchar_unlocked();
	int f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-f;
		}
		ch=getchar_unlocked();
	}
	while(ch<='9'&&ch>='0'){
		x=(x<<1)+(x<<3)+ch-48;
		ch=getchar_unlocked();
	}
	x*=f;
}
int js[Maxw];
int w[Maxn];
int ans=0,sum=0,www=0;
int A(int x,int y){
	int a=1,b;
	for(int i=1;i<=x;i++){
		a*=(y-i+1);
		a%=md;
	}
	return a;
}
int n;
int dfs(int p,int l,int ww){
	if(ww<=0){
		return 0;
	}
	if(p==n-js[0]+1&&l==sum&&ww>0){
		ans+=ww;
		ans%=md;
		return ww;
	}
	if(l>=www){
		ans+=ww*w[n-js[0]+1-p];
		ans%=md;
		return ww*w[n-js[0]+1-p]%md;
	}
	int wwwww=0;
	for(int i=1;i<=www;i++){
		wwwww*=base;
		wwwww+=js[i];
		wwwww%=md;
	}
	if(mymap.count(wwwww)){
		if(mymap[wwwww]<=0){
			return 0;
		}
		ans+=mymap[wwwww];
		ans%=md;
		return mymap[wwwww];
	}
	int wwwwww=0;
	bool bj=0;
	for(int i=1;i<=l;i++){
		if(js[i]!=0){
			js[i]--;
			bj=1;
			wwwwww+=dfs(p+1,l+i,ww*(js[i]+1)%md);
			wwwwww%=md;
			js[i]++;
		}
	}
	if(!bj){
		mymap[wwwww]=0;
		return 0;
	}
	mymap[wwwww]=wwwwww;
	return wwwwww;
}
signed main(){
	read(n);
	w[0]=1;
	int cs;
	read(cs);
	for(int i=1;i<=n;i++){
		int val;
		read(val);
		js[val]++;
		sum+=val;
		www=max(www,val);
		w[i]=w[i-1]*i;
		w[i]%=md;
	}
	dfs(1,cs,1);
	if(ans==0&&js[0]==n){
		ans=1;
	}
	ans*=A(js[0],n);
	printf("%lld",max(ans,(long long)0)%md);
	return 0;
}
2024/10/4 08:28
加载中...