QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307000#8015. 鸡PubabaOnO10 2ms3652kbC++173.2kb2024-01-17 19:20:382024-01-17 19:20:38

Judging History

你现在查看的是最新测评结果

  • [2024-01-17 19:20:38]
  • 评测
  • 测评结果:10
  • 用时:2ms
  • 内存:3652kb
  • [2024-01-17 19:20:38]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}


#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
 
#define maxn 300005
#define inf 0x3f3f3f3f

int n,m;

int f[maxn];
int F(vi a){
	int n=a.size();
	For(i,1,n){
		if(i>=2) f[i]=f[i-2]+a[i-1];
		else f[i]=a[i-1];
		f[i]=max(f[i],f[i-1]);
	}
	return f[n];
}

int a[maxn];
map<vi,set<vi> >mp;
void chk(){
	vi o;
	For(i,0,n-1) o.pb(a[i+1]);
//	For(i,0,n-1) cout<<o[i]<<" "; cout<<"\n";
	vi res;
	For(i,0,n-1) {
		o[i]=0;
		res.pb(F(o));
		o[i]=a[i+1];
	}
	int t=F(o);
	//For(i,0,n-1) cout<<res[i]<<" "; cout<<"\n";
	vi res2;
	For(i,0,n-1) res2.pb(t-res[i]);
	mp[res2].insert(res);
}
void dfs(int u){
	if(u==n+1){
		chk();
		return;
	}
	For(i,0,m)a[u]=i,dfs(u+1);
}

signed main()
{
	n=read(),m=read(),dfs(1);
	int res=0;
	for(auto [t1,t2]:mp){
		res+=t2.size();
//		for(auto it:t2){
//			for(auto x:it)cout<<x<<" ";
//			cout<<"\n";
//		}cout<<"--------\n";
	}
	cout<<res;
	return 0;
}
/*
6 17 36 65 106 161 232 321 430 561 716 897 1106 1345 1616 1921 2262
12
47
120
245
436 
707
1072
*/
/*

*/

详细

Test #1:

score: 5
Accepted
time: 2ms
memory: 3652kb

input:

5 5 1004326439

output:

1281

result:

ok 1 number(s): "1281"

Test #2:

score: 5
Accepted
time: 2ms
memory: 3576kb

input:

5 4 1002682123

output:

649

result:

ok 1 number(s): "649"

Test #3:

score: 0
Time Limit Exceeded

input:

287 1 1003060133

output:


result:


Test #4:

score: 0
Time Limit Exceeded

input:

279 1 1004432189

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

300 1 1005912203

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

288 5 1003307827

output:


result:


Test #7:

score: 0
Time Limit Exceeded

input:

281 5 1008854383

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

270 5 1007619367

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

292 5 1002449813

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

300 5 1005897091

output:


result:


Test #11:

score: 0
Time Limit Exceeded

input:

45 50 1009100993

output:


result:


Test #12:

score: 0
Time Limit Exceeded

input:

49 50 1001428049

output:


result:


Test #13:

score: 0
Time Limit Exceeded

input:

49 50 1007851073

output:


result:


Test #14:

score: 0
Time Limit Exceeded

input:

50 50 1005625571

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

290 300 1005068699

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

270 300 1003440637

output:


result:


Test #17:

score: 0
Time Limit Exceeded

input:

300 300 1008561979

output:


result:


Test #18:

score: 0
Time Limit Exceeded

input:

2991 3000 1004658859

output:


result:


Test #19:

score: 0
Time Limit Exceeded

input:

2870 3000 1004054173

output:


result:


Test #20:

score: 0
Time Limit Exceeded

input:

3000 3000 1009539589

output:


result: