QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#389401#1085. Brave Seekers of UnicornsSroundTL 0ms0kbC++141.1kb2024-04-14 11:28:122024-04-14 11:28:13

Judging History

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

  • [2024-04-14 11:28:13]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-14 11:28:12]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

inline int read()
{
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=1;ch=getchar();}
	while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f?-x:x;
}

#define x first
#define y second
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ull;
const int N=510;

int n,MOD;
int f[N][N][N];
int sum[N][N];

void solve1()
{
	rep(i,1,n) f[1][i][0]=sum[1][i]=1;
	rep(i,2,n) {
		sum[2][i]=i-1;
		rep(j,1,i-1) f[2][i][j]=1;
	}
	rep(i,3,n) rep(j,i,n) rep(k,i-1,j-1) {
		f[i][j][k]=((sum[i-1][k]-(j^k<=n?f[i-1][k][j^k]:0))%MOD+MOD)%MOD;
		(sum[i][j]+=f[i][j][k])%=MOD;
	}
	
	int ans=0;
	// cout<<sum[3][3]<<endl;
	rep(i,1,n) rep(j,i,n) ans=(ans+sum[i][j])%MOD;
	printf("%d\n",ans);
}

void solve2()
{
	
}

int main()
{
	n=read(),MOD=read();
	if(n==1) puts("1");
	else if(n<=500) solve1();
	else if(n<=5000) solve2();
	else puts("0");
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: