QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#867499#9684. 倾诉lgvc#0 3846ms6416kbC++234.9kb2025-01-23 17:18:472025-01-23 17:18:48

Judging History

This is the latest submission verdict.

  • [2025-01-23 17:18:48]
  • Judged
  • Verdict: 0
  • Time: 3846ms
  • Memory: 6416kb
  • [2025-01-23 17:18:47]
  • Submitted

answer

#include <bits/stdc++.h>
#define BIT 61
#define SIZ 350
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[20009];
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: 1ms
memory: 3840kb

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
Wrong Answer

Test #60:

score: 0
Wrong Answer
time: 201ms
memory: 3840kb

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:

wrong answer 1st lines differ - expected: '110000100100000', found: '110000100000000'

Subtask #6:

score: 0
Time Limit Exceeded

Test #80:

score: 16
Accepted
time: 403ms
memory: 3840kb

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:

ok 3333 lines

Test #81:

score: 16
Accepted
time: 441ms
memory: 3840kb

input:

2000
10 1000000000
4 225227 95031 258432 108444 260818 190505 154686 1 5
10 1000000000
541067 480522 7 372550 533382 366492 200177 240412 6 1
10 1000000000
10004 14230 86468 2812 9690 7106 21976 45928 9749 30567
10 1000000000
12217 2718 4247 9981 12911 1845 2048 4 1387 16384
10 1000000000
46966 1438...

output:

11110100000110100010000000
101001100100010010010000000
1111111110010010000000000
1000000000000000000000000
11010100011000000000
110010110111010010100000000
11000010111011011011000000000
1001001110000111010000000000
11110110001100100100000000
101110111011100111000000000
100001001101001011110000000
10...

result:

ok 2000 lines

Test #82:

score: 16
Accepted
time: 627ms
memory: 3968kb

input:

800
25 1000000000
87944 70771 86657 342502 146802 122800 216223 248367 121688 22026 9518 1128 64025 63379 231058 292954 218186 35314 64373 10501 20550 32081 39386 10095 78181
25 1000000000
54665 3 129508 98607 92526 68177 57466 62726 21642 52766 23748 16110 18286 9033 4 6 3 6 2 5 7 5 7 1 4
25 100000...

output:

100110001011001010000000000000000000000000
11001101110010100000000000000
1101110010100110110000000000000000000000
1011101001000100000000000000000000000000
10100110000000000000000000000000
1001111010011010010000000000000000000000
10010000010110010011000000000000000000000000
10000010010000000000000000...

result:

ok 800 lines

Test #83:

score: 16
Accepted
time: 988ms
memory: 3968kb

input:

400
50 1000000000
36192 37096 41075 279152 132449 170424 203877 76049 163616 193360 220325 66999 100454 253404 184659 123538 175852 228265 36430 14534 5082 24007 9240 14589 22365 47490 42236 267799 144852 218552 99653 6256 50634 80363 90985 168540 213317 114099 2231 11664 17529 37776 44616 44454 102...

output:

11010001010111010000000000000000000000000000000000000000000000000
1100100111001001000000000000000000000000000000000000000000000000
100011011111111110000000000000000000000000000000000000000000000000
111000010111000000000000000000000000000000000000000000000000
11010001100000000000000000000000000000000...

result:

ok 400 lines

Test #84:

score: 16
Accepted
time: 1747ms
memory: 4096kb

input:

200
100 1000000000
99999 166651 172330 201875 281584 356526 387368 439633 573276 7 589135 554082 510762 510397 480338 447887 425040 385075 276710 246377 209934 170427 48543 40575 32050 1 505193 443771 362419 314334 311097 166747 98814 76005 2 10873 14027 30940 63000 69322 74238 141599 179046 183231 ...

output:

100011000010000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
101110111001101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1011000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 200 lines

Test #85:

score: 16
Accepted
time: 2540ms
memory: 4224kb

input:

133
150 1000000000
1942 801 89 110 53 71 56 89 43 107172 74849 78209 81044 26034 72943 20353 159713 1904 259866 59454 130859 49737 129495 27090 42758 133410 214036 201815 47 166 49 103 16 7298 26210 91925 198065 158 384 430 255 348 437 391 249 303 140 21494 204750 131296 60676 94483 261236 65302 244...

output:

11100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100011100101101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 133 lines

Test #86:

score: 16
Accepted
time: 3257ms
memory: 4480kb

input:

100
200 1000000000
68988 89086 7535 29066 45938 115647 147461 36265 29182 53020 24083 195128 142671 97759 132186 88028 84300 44019 25085 21501 38052 25645 294 23101 183153 51327 20117 123035 33735 19868 25692 77782 18038 87484 41683 47422 30012 64925 37422 57891 38887 40214 62062 16612 57733 23508 5...

output:

10101011101001001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100000100000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 100 lines

Test #87:

score: 16
Accepted
time: 3846ms
memory: 6416kb

input:

80
250 1000000000
2 1 1 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 17442 ...

output:

1011110001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1100011011000110000000000000000000000000000...

result:

ok 80 lines

Test #88:

score: 0
Time Limit Exceeded

input:

50
400 1000000000
7 4 3 5 5 5 4 7 7 5 3 2 1 3 208121 12815 77917 77917 292407 93104 16701 77917 77917 140969 46391 77917 77917 77917 77917 77917 157905 37923 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 77917 7791...

output:

110010001001110001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:


Subtask #7:

score: 0
Skipped

Dependency #4:

0%