QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671187#8965. JeloCrysfly100 ✓75ms3860kbC++144.2kb2024-10-24 11:32:482024-10-24 11:32:48

Judging History

This is the latest submission verdict.

  • [2024-10-24 11:32:48]
  • Judged
  • Verdict: 100
  • Time: 75ms
  • Memory: 3860kb
  • [2024-10-24 11:32:48]
  • 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;
		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: 3584kb

input:

18

output:

512
0 513 1032 1551 2112 2645 3192 3691 4099 4682 5291 5860 6595 7070 7515 7936 8216 8969 9299 10052 10590 10843 11557 11814 12305 13128 13562 14245 14551 15258 15372 16199 16576 17127 17476 18021 18587 19112 19503 19994 20735 21136 21723 22194 22820 23391 23856 24397 24712 25535 25679 26494 27093 2...

result:

points 1.0 OK, |S| = 512

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 2ms
memory: 3592kb

input:

20

output:

1024
0 1025 2056 3087 4160 5205 6264 7275 8704 9801 10920 12007 13248 14237 15192 16131 16420 17717 19052 20347 20845 21608 23317 24086 25151 26470 26839 28040 29430 30651 30766 32101 33056 34056 35258 36244 37700 38776 39918 40916 41850 42778 43840 44838 45214 46314 47252 48358 49628 50404 51974 52...

result:

points 1.0 OK, |S| = 1024

Subtask #3:

score: 20
Accepted

Test #3:

score: 20
Accepted
time: 16ms
memory: 3860kb

input:

26

output:

8192
0 8193 16392 24591 32832 41045 49272 57451 66048 74313 82600 90855 99264 107421 115544 123651 135168 143633 152136 160607 169280 177221 186168 194107 204288 212825 220392 228791 236224 244621 251928 260435 262252 271437 280804 289987 299564 308761 318100 327335 330359 339486 344671 353840 36703...

result:

points 1.0 OK, |S| = 8192

Subtask #4:

score: 20
Accepted

Test #4:

score: 20
Accepted
time: 35ms
memory: 3700kb

input:

28

output:

16384
0 16385 32776 49167 65600 82005 98424 114795 131584 148041 164520 180967 197568 213917 230232 246531 266240 282897 299592 316255 333120 349253 366392 382523 400896 417625 433384 449975 465600 482189 497688 514387 524354 541795 559306 576749 594434 611895 629434 646793 666178 683563 696938 7142...

result:

points 1.0 OK, |S| = 16384

Subtask #5:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 75ms
memory: 3708kb

input:

30

output:

32768
0 32769 65544 98319 131136 163925 196728 229483 262656 295497 328360 361191 394176 426909 459608 492291 528384 561425 594504 627551 660800 693317 726840 759355 794112 827225 859368 892343 924352 957325 989208 1022291 1048579 1082402 1116299 1150124 1184323 1218166 1252091 1285832 1321475 13553...

result:

points 1.0 OK, |S| = 32768