QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#867492#9684. 倾诉lgvc#0 74ms9004kbC++234.9kb2025-01-23 17:13:562025-01-23 17:13:57

Judging History

This is the latest submission verdict.

  • [2025-01-23 17:13:57]
  • Judged
  • Verdict: 0
  • Time: 74ms
  • Memory: 9004kb
  • [2025-01-23 17:13:56]
  • Submitted

answer

#include <bits/stdc++.h>
#define BIT 61
#define SIZ 35000
struct bitset {
	long long bits[SIZ];
	void init(void) {for(int i=0;i<SIZ;i++) bits[i]=0;} 
	void set(int x,bool y) {bits[x/BIT]^=((((bits[x/BIT]>>(x%BIT))&1)^y)<<(x%BIT));}
	void setall(bool y) {for(int i=0;i<SIZ;i++) bits[i]=((((long long)y)<<BIT)-(long long)(y));}
	bool q(int x) {return (bits[x/BIT]>>(x%BIT))&1;}
	void operator=(const bitset& y) {for(int i=0;i<SIZ;i++) bits[i]=y.bits[i];}
	void operator|=(const bitset& y) {for(int i=0;i<SIZ;i++) bits[i]|=y.bits[i];}
	void operator&=(const bitset& y) {for(int i=0;i<SIZ;i++) bits[i]&=y.bits[i];}
	void operator^=(const bitset& y) {for(int i=0;i<SIZ;i++) bits[i]^=y.bits[i];}
	void operator+=(const bitset& y) {
		for(int i=0;i<SIZ;i++) {
			bits[i]+=y.bits[i];
			if((bits[i]>>BIT)&1) bits[i]^=(1ll<<BIT),bits[i+1]++;
		}
	}
	void operator-=(const bitset& y) {
		for(int i=0;i<SIZ;i++) {
			bits[i]-=y.bits[i];
			if(bits[i]<0) bits[i]+=(1ll<<BIT),bits[i+1]--;
		}
	}	
	void operator<<=(int k) {
		bitset z;z.init();
		int tmp=k/BIT;
		for(int i=0;i<SIZ-tmp;i++) z.bits[i+tmp]=bits[i];
		k%=BIT;
		z.bits[SIZ-1]<<=k;
		for(int i=SIZ-2;i>=0;i--) {
			long long tmp=z.bits[i];
			z.bits[i]&=((1ll<<(BIT-k))-1);
			z.bits[i+1]|=((tmp^z.bits[i])>>(BIT-k));
			z.bits[i]<<=k;
		}
		for(int i=0;i<SIZ;i++) bits[i]=z.bits[i];
	}
	void operator>>=(int k) {
		bitset z;z.init();
		int tmp=k/BIT;
		for(int i=tmp;i<SIZ;i++) z.bits[i-tmp]=bits[i];
		k%=BIT;
		z.bits[0]>>=k;
		for(int i=1;i<SIZ;i++) {
			z.bits[i-1]|=((z.bits[i]&((1ll<<k)-1))<<(BIT-k));
			z.bits[i]>>=k;
		}
		for(int i=0;i<SIZ;i++) bits[i]=z.bits[i];
	}	
	bitset operator|(const bitset& y) {
		bitset z;
		for(int i=0;i<SIZ;i++) z.bits[i]=bits[i]|y.bits[i];
		return z;
	}
	bitset operator&(const bitset& y) {
		bitset z;
		for(int i=0;i<SIZ;i++) z.bits[i]=bits[i]&y.bits[i];
		return z;
	}
	bitset operator^(const bitset& y) {
		bitset z;
		for(int i=0;i<SIZ;i++) z.bits[i]=bits[i]^y.bits[i];
		return z;
	}	
	bitset operator+(const bitset& y) {
		bitset z;z.bits[0]=0;
		for(int i=0;i<SIZ;i++) {
			z.bits[i]+=bits[i]+y.bits[i];
			if((z.bits[i]>>BIT)&1) z.bits[i]^=(1ll<<BIT),z.bits[i+1]=1;else z.bits[i+1]=0;
		}
		return z;
	}
	bitset operator-(const bitset& y) {
		bitset z;z.bits[0]=0;
		for(int i=0;i<SIZ;i++) {
			z.bits[i]+=bits[i]-y.bits[i];
			if(z.bits[i]<0) z.bits[i]+=(1ll<<BIT),z.bits[i+1]=-1;else z.bits[i+1]=0;
		}
		return z;
	}
	bitset operator<<(int k) {
		bitset z;z.init();
		int tmp=k/BIT;
		for(int i=0;i<SIZ-tmp;i++) z.bits[i+tmp]=bits[i];
		k%=BIT;
		z.bits[SIZ-1]<<=k;
		for(int i=SIZ-2;i>=0;i--) {
			long long tmp=z.bits[i];
			z.bits[i]&=((1ll<<(BIT-k))-1);
			z.bits[i+1]|=((tmp^z.bits[i])>>(BIT-k));
			z.bits[i]<<=k;
		}
		return z;
	}
	bitset operator>>(int k) {
		bitset z;z.init();
		int tmp=k/BIT;
		for(int i=tmp;i<SIZ;i++) z.bits[i-tmp]=bits[i];
		k%=BIT;
		z.bits[0]>>=k;
		for(int i=1;i<SIZ;i++) {
			z.bits[i-1]|=((z.bits[i]&((1ll<<k)-1))<<(BIT-k));
			z.bits[i]>>=k;
		}
		return z;
	}	
	int count(void) {
		int ans=0;
		for(int i=0;i<SIZ;i++) ans+=__builtin_popcountll(bits[i]);
		return ans;
	}
	bool operator<(const bitset& y) {
		for(int i=SIZ-1;i>=0;i--) if(bits[i]^y.bits[i]) return bits[i]<y.bits[i];
		return 0;
	}
	bool operator>(const bitset& y) {
		for(int i=SIZ-1;i>=0;i--) if(bits[i]^y.bits[i]) return bits[i]>y.bits[i];
		return 0;
	}
	bool operator<=(const bitset& y) {
		for(int i=SIZ-1;i>=0;i--) if(bits[i]^y.bits[i]) return bits[i]<y.bits[i];
		return 1;
	}
	bool operator>=(const bitset& y) {
		for(int i=SIZ-1;i>=0;i--) if(bits[i]^y.bits[i]) return bits[i]>y.bits[i];
		return 1;
	}
	bool operator==(const bitset& y) {
		for(int i=SIZ-1;i>=0;i--) if(bits[i]^y.bits[i]) return 0;
		return 1;
	}
}; 
bitset max(bitset& x,bitset& y) {
	for(int i=SIZ-1;i>=0;i--) {
		if(x.bits[i]>y.bits[i]) return x;
		if(x.bits[i]<y.bits[i]) return y;
	}
	return x;
}
bitset min(bitset& x,bitset& y) {
	for(int i=SIZ-1;i>=0;i--) {
		if(x.bits[i]>y.bits[i]) return y;
		if(x.bits[i]<y.bits[i]) return x;
	}
	return x;
}
int T,N,a[20009],K;
bitset f[755];
int dp[755][755];
bool chk(bitset x) {
	int l=N,p=N;
	bitset va;
	va.setall(0);
	while(l) {
		va+=(f[l]>>p-l);
		if(va>x) {
			if(p==l) {
				return 0;
			}
			p--;
			va.setall(0);
			continue;
		} else {
			l--;
		}
	}
	return 1;
}
signed main(void) {
	scanf("%d",&T);
//	T=1;
	while(T--) {
		std::mt19937 rng(114);
		scanf("%d %d",&N,&K);
//		N=750;K=10000;
		for(int i=1;i<=N;i++) {
			scanf("%d",&a[i]);
//			a[i]=rng()%1000000+1;
			f[i].setall(0);
			f[i].bits[0]=a[i];
			f[i]<<=N;
		}
		bitset ff;
		for(int i=N+20;i>=0;i--) ff.set(i,1);
		for(int i=N+20;i>=0;i--) {
			ff.set(i,0);
			if(!chk(ff)) {
				ff.set(i,1);
			}
		}
		int st=0;
		for(int i=N+20;i>=0;i--) {
			if(ff.q(i)) {
				st=i;
				break;
			}
		}
		for(int i=st;i>=0;i--) printf("%d",ff.q(i));
		printf("\n");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 74ms
memory: 9004kb

input:

5
6 1
11764 28428 28179 18698 6443 20288
6 3
29 17548 61962 31242 8172 4107
6 15
7 2 239427 137145 171239 3
6 4
294 211 407 190 2 2
6 5
197190 265870 12121 144584 21313 14169

output:

100111101000000000000
11111010000011100000
11101001110100001100000
1100101011000
1110111000101011100000

result:

wrong answer 1st lines differ - expected: '110111100001100000000', found: '100111101000000000000'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Time Limit Exceeded

Test #60:

score: 0
Time Limit Exceeded

input:

1666
6 1
282 719 29 355 388 275
6 1
348 766 91 299 474 96
6 23
5 2 8554 8554 8554 2
6 1
84 195 23 37 120 117
6 3
8 3 51 62 28 5
6 3
3 64 64 4 4 2
6 9
5 552 552 552 552 5
6 3
3611 1144 417 3461 459 755
6 3
777 315 1007 5 2 1061
6 6
1300 2101 4 1877 360 2434
6 1
384 713 168 25 524 390
6 3
203 18 305 1...

output:

110000100000000
101001101000000
1000010110111000000
1111000000000
11111000000
1101000000
100011001000000
11011000010100000
10000100101000000
100110000010000000
1000001100000000
1111001000000
111001011010000000
1100000110100000
1101110100000000
101011111000000
10010110000
100101000000000
101111001010...

result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #80:

score: 0
Time Limit Exceeded

input:

3333
6 1000000000
131727 7 4 170194 6 59263
6 1000000000
417714 286613 7 310122 6 4
6 1000000000
63764 2430 2696 6699 8478 22261
6 1000000000
217 131 6 1487 2927 2
6 1000000000
26225 27991 3842 72525 4521 5231
6 1000000000
34409 26001 23563 19345 30764 24919
6 1000000000
97981 138532 59280 82393 128...

output:

10100110001101001000000
10010111011100001100000
101011011110101000000
10110111001100000
110010000010110110000
111100110010110100000
11111011000100010000000
11001111100101100
1100000101001001010100000
100000000000
100111000110001000000
101110110010100111000000
10000000000000000000000
1100000111101000...

result:


Subtask #7:

score: 0
Skipped

Dependency #4:

0%