QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671091#8965. JeloCrysfly60 145ms3944kbC++144.2kb2024-10-24 10:48:592024-10-24 10:49:00

Judging History

This is the latest submission verdict.

  • [2024-10-24 10:49:00]
  • Judged
  • Verdict: 60
  • Time: 145ms
  • Memory: 3944kb
  • [2024-10-24 10:48:59]
  • Submitted

answer

// what is matter? never mind.
#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 int 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;
}

int mod;
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 55
#define inf 0x3f3f3f3f
#define poly vector<modint>

int n,p,k;

poly operator +(poly a,poly b){
	int n=max(a.size(),b.size());a.resize(n),b.resize(n);
	For(i,0,n-1)a[i]+=b[i];return a;
}
poly operator -(poly a,poly b){
	int n=max(a.size(),b.size());a.resize(n),b.resize(n);
	For(i,0,n-1)a[i]-=b[i];return a;
}
poly operator *(poly a,modint b){
	int n=a.size();
	For(i,0,n-1)a[i]*=b;return a;
} 
poly operator *(poly a,poly b){
	if(!a.size()||!b.size())return {};
	poly c(a.size()+b.size()-1,0);
	for(int i=0;i<a.size();++i)
		for(int j=0;j<b.size();++j)
			c[i+j]+=a[i]*b[j];
	return c;
}

poly operator %(poly a,poly b){
	while(b.back().x==0)b.pop_back();
	while(1){
		while(a.size()&&a.back().x==0)a.pop_back();
		if(a.size()<b.size())return a;
		int t=a.size()-b.size();
		modint w=a.back()/b.back();
		For(i,0,(int)b.size()-1)a[i+t]-=b[i]*w;
		assert(a.back().x==0);
	}
}

void init(poly &a,int x){
	if(a.size()<k)a.resize(k);
	For(i,0,k-1)a[i]=x%p,x/=p;
}
int get(poly a){
	if(a.size()<k)a.resize(k);
	int res=0;
	Rep(i,k-1,0)res=res*p+a[i].x;
	return res;
}

bool chk(poly a){
	poly b;
	For(i,p,n-1){
		init(b,i);
		poly c=a%b;
		if(!c.size())return 0;
	}
	return 1;
}

poly qwq(){
	poly a(k+1); a[k]=1;
	For(i,1,n-1){
		init(a,i);
		if(chk(a))return a;
	}
	assert(0);
}

int pri[maxn],pc[maxn],tot;
void fj(int n){
	For(i,2,n)
		if(n%i==0){
			pri[++tot]=i;
			while(n%i==0)n/=i,++pc[tot];
		}
}

signed main()
{
	n=1<<read();
	k=0;
	while((1<<(k*2))<n)k++;
	n=(1<<k);
	mod=p=2;
	poly a;
	a=qwq();//puts("QWQWQ");
//	for(auto x:a)cout<<x.x<<' ';puts(" A");
	vi o;
	int s=(1<<k);
	For(i,0,(1<<k)-1){
		poly x; init(x,i);
		poly y=x*x%a*x%a*x%a*x%a;
		int out=get(y);
		out|=(i<<k);
		o.pb(out);
	}
	cout<<o.size()<<"\n";
	for(int x:o)cout<<(x)<<" \n"[x==o.back()];
	
//	set<int>S;
//	For(i,0,s-1)
//		For(j,i+1,s-1){
//			if(S.count(o[i]^o[j])) assert(0);
//			S.insert(o[i]^o[j]);
//		}
//	For(i,0,s-1) if(!S.count(i)) {
//		bool ok=1;
//		for(int x:o) if(S.count(i^x)) {
//			ok=0;
//			break;
//		}
//		if(ok){
//			cout<<"add "<<i<<"\n";
//		}
//	}
	return 0;
}
// (1 0 1) % 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3824kb

input:

18

output:

512
0 513 1056 1587 2054 2819 3173 3954 4288 4817 5200 5715 6314 7103 7289 8062 8212 9093 9271 10164 10255 10906 11375 12008 12638 13023 13773 13918 14633 15276 15865 16238 16515 17078 17544 18095 18661 19412 19629 20366 20960 21445 21851 22380 23018 23243 23826 24097 25087 25178 26103 26176 27012 2...

result:

points 1.0 OK, |S| = 512

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 3ms
memory: 3612kb

input:

20

output:

1024
0 1025 2080 3123 4105 5388 6761 8062 8480 9485 10696 11767 12715 13442 15107 15928 16449 17936 18920 20395 20862 22059 23191 24016 24837 26488 26724 28171 28856 30657 31641 31986 32818 33874 35472 36578 37239 37907 39317 40163 41875 42975 43513 44455 45652 46876 47742 48932 49384 50904 52163 52...

result:

wrong answer wrong plan

Subtask #3:

score: 20
Accepted

Test #3:

score: 20
Accepted
time: 29ms
memory: 3660kb

input:

26

output:

8192
0 8193 16416 24627 33792 42245 50784 59255 65644 77925 82135 94412 101466 114007 118433 131006 134528 142665 150800 159179 170720 178989 186416 195055 199668 211765 216063 228140 234658 238951 251625 255806 266415 277774 280975 287804 295599 306698 317903 324984 335198 336119 345317 358750 3623...

result:

points 1.0 OK, |S| = 8192

Subtask #4:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 66ms
memory: 3944kb

input:

28

output:

16384
0 16385 32800 49203 66560 83205 99936 116599 131138 151627 172258 192761 199779 220526 241283 262044 264256 280789 297064 313583 335440 352193 367672 384443 396454 416827 437262 457857 463511 475918 503935 516596 526468 540901 563748 578135 593284 607457 630116 644115 658415 676742 702927 7131...

result:

wrong answer wrong plan

Subtask #5:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 145ms
memory: 3728kb

input:

30

output:

32768
0 32769 65568 98355 132096 165125 198240 231287 262147 299018 336035 372920 412675 449806 487139 524284 524384 557175 590156 622921 660600 693611 726804 759317 786517 823370 860665 897524 941133 970070 1015713 1044136 1051648 1084481 1117920 1150643 1190272 1222853 1255712 1288311 1314575 1351...

result:

points 1.0 OK, |S| = 32768