QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290239#7967. 二进制daydream#WA 398ms261100kbC++202.1kb2023-12-24 16:30:172023-12-24 16:30:17

Judging History

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

  • [2023-12-24 16:30:17]
  • 评测
  • 测评结果:WA
  • 用时:398ms
  • 内存:261100kb
  • [2023-12-24 16:30:17]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
#define LL long long
#define pb push_back
#define eb emplace_back
#define pli pair<LL,int>
#define pii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
const int dx[]={0,1,0,-1,1,1,-1,-1},
		  dy[]={1,0,-1,0,1,-1,1,-1};

struct BIT
{
	int n;
	vector<int> tr;
	BIT(int N)
	{
		tr.resize((n=N)+10);
	}
	void upd(int i) {for(;i<=n;i+=(i&-i)) tr[i]++;}
	int qry(int i) {int res=0; for(;i;i-=(i&-i)) res+=tr[i]; return res;}
};
int n;
void solve()
{
	cin>>n;
	string s;cin>>s;s=" "+s;
	vector<int> a(n+10),f(n+10),ex(n+10,1),nxt(n+10),pre(n+10),cnt(n*2+10);
	vector<priority_queue<int,vector<int>,greater<int>>> pos(n*2+10),del(n*2+10);
	nxt[n+1]=n+1;nxt[0]=1;pre[n+1]=n;
	for(int i=1;i<=n;++i) a[i]=s[i]-'0',nxt[i]=i+1,pre[i]=i-1;
	BIT T(n);
	for(int k=1,x=1;x<=n;++k,x<<=1)
	{
		int S=(1<<k)-1;
		{
			int p=nxt[0],ps=p,x=0;
			for(int j=1;j<k;++j,ps=nxt[ps]) x=x<<1|a[ps];
			for(;ps<=n;p=nxt[p],ps=nxt[ps])
			{
				x=((x<<1)&S)|a[ps];
				f[p]=x;
				cnt[f[p]]++;pos[f[p]].push(p);
			}
			for(;p<=n;p=nxt[p]) f[p]=0;
		}
//		cout<<'\n';
		for(int i=x;i<=n&&i<(x<<1);++i)
		{
//			cout<<cnt[7]<<'\n';
			if(cnt[i]<=0)
			{
				cout<<"-1 0\n";
				continue;
			}
			while(!del[i].empty()&&pos[i].top()==del[i].top())
			{
				pos[i].pop();
				del[i].pop();
			}
			int P=pos[i].top(),p=P;
			cout<<p-T.qry(p)<<' '<<cnt[i]<<'\n';
			for(int j=1;j<=k;++j,p=nxt[p])
			{
				ex[p]=0;
				T.upd(p);
				cnt[f[p]]--;
				del[f[p]].push(p);
				f[p]=0;
			}
			nxt[pre[P]]=p;pre[p]=pre[P];
			p=P;
			for(int j=1;j<k;++j) p=pre[p];
			if(!p) p=nxt[p];
			int x=0,ps=p;
			for(int j=1;j<k;++j,ps=nxt[ps]) x=x<<1|a[ps];
			for(int j=1;j<k;++j,p=nxt[p],ps=nxt[ps])
			{
				if(f[p])
				{
					cnt[f[p]]--;
					del[f[p]].push(p);
				}
				if(ps<=n)
				{
					x=((x<<1)&S)|a[ps];
					f[p]=x;
					cnt[f[p]]++;pos[f[p]].push(p);
				}
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int TT=1;
//	cin>>TT;
	for(;TT;--TT) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

20
01001101101101110010

output:

2 11
5 5
4 5
11 1
4 2
7 1
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0

result:

ok 20 lines

Test #2:

score: 0
Accepted
time: 126ms
memory: 242392kb

input:

1000000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 1000000
-1 0
1 999998
-1 0
-1 0
-1 0
1 999995
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
1 999991
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
1 999986
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0...

result:

ok 1000000 lines

Test #3:

score: 0
Accepted
time: 279ms
memory: 255784kb

input:

1000000
1111111101011101110011011111111111111110110011110111011100111001011011011110101110111111111111111111111111011111101111110110111111111110111010111111100110011101101110011111111101111110111111111110111111111111011011110110111101101101110101100111111111001010111111111111010111011111111011110111...

output:

1 800681
7 159535
1 641144
13 31730
5 127804
5 127761
1 513379
542 6405
25 25324
54 25337
5 102464
30 25561
17 102196
17 102484
1 410890
2647 1324
618 5080
20 5103
99 20219
304 4894
89 20442
21 20308
15 82150
810 5135
82 20422
158 20309
20 81880
83 20567
39 81909
40 82119
1 328769
4222 267
2829 1056...

result:

ok 1000000 lines

Test #4:

score: 0
Accepted
time: 263ms
memory: 254116kb

input:

1000000
1101111101110111111111011101011111110111101001111110111111110100111111001011111011110011111011100111111111111111010001111110011010101111111111011100110111010101111111111111111110110111001101111111100111111011110111111111111111101111111110101010011111101110111111111111111111111101111110111111...

output:

1 800315
1 159901
1 640412
38 31850
3 128050
3 128165
1 512243
97 6369
45 25480
12 25565
8 102482
40 25580
13 102583
13 102460
1 409776
295 1288
274 5080
345 4929
39 20549
187 5053
73 20509
118 20499
14 81980
447 5084
39 20492
84 20487
17 82091
52 20447
16 82006
16 82071
1 327699
441 231
571 1056
28...

result:

ok 1000000 lines

Test #5:

score: 0
Accepted
time: 246ms
memory: 256672kb

input:

1000000
1011101110000111111111111010111100111001110111111101111110010111011011101111111111111111011111111011111111111111110110111111111110111111001011111101110111111011111111111111111011110011111011111100011111110110111111110110111100111101111111111011111111111011110111101111101011111111111111111111...

output:

1 799990
4 159695
2 640293
4 32324
17 127370
2 127967
3 512321
177 6381
15 25942
244 25350
10 102018
11 25885
12 102077
15 102178
3 410139
2620 1289
753 5091
16 5090
134 20850
959 5103
279 20246
18 20591
20 81421
770 5138
79 20743
292 20352
31 81720
147 20754
34 81414
45 81806
3 328330
6959 252
3565...

result:

ok 1000000 lines

Test #6:

score: 0
Accepted
time: 272ms
memory: 254068kb

input:

1000000
1001011111111110110111110111100110111110111111111111111111111101110111010010110101111101101101111010100111110111111101111111111101001111101100100101111111111110010011111111100111111110110111101111111111101111111111111111111101111111111111010100001111110111100111011110101111111111111101111101...

output:

1 799378
3 160096
3 639280
24 32304
10 127791
9 127869
3 511407
225 6534
55 25770
57 25712
10 102073
48 25844
11 102022
12 102244
3 409159
808 1350
451 5183
95 5244
56 20525
78 5110
52 20603
41 20369
29 81699
941 5203
83 20637
66 20630
27 81387
70 20753
30 81486
30 81965
3 327185
7290 264
1512 1085
...

result:

ok 1000000 lines

Test #7:

score: 0
Accepted
time: 294ms
memory: 254356kb

input:

1000000
1110011111011011101101111110010111111111011111101111111011011001111110101110010111110111101101111011011111010101111011111010110001001101110111110101111111101101111111111111101100011110101011101111100111100111010100111111010101001111101111111111010111111011010101110111011111111110111011111100...

output:

1 749001
2 188027
3 560972
22 47144
1 140882
1 140831
4 420138
109 11902
2 35242
48 35463
2 105414
35 35381
4 105445
9 105566
1 314570
671 2951
127 8950
30 8758
76 26482
146 8914
56 26546
18 26627
10 78783
547 8948
117 26429
55 26351
23 79089
107 26490
22 79070
19 78934
1 235630
2187 735
606 2215
20...

result:

ok 1000000 lines

Test #8:

score: 0
Accepted
time: 302ms
memory: 256260kb

input:

1000000
1111111111111110111101101111011101111101110111001111011111101111111111101111001111011101111101111001111100101010111100101111111111111011011111011001111111111111111101111111001110111101111111111110011111111111110111011010010111010111110111111111110001111111111111111011010011110111010011111011...

output:

1 749933
14 187494
1 562437
41 46840
15 140653
14 141001
1 421432
229 11754
59 35085
86 34888
14 105763
71 35195
13 105802
14 105692
1 315736
510 2914
520 8839
63 8754
95 26329
162 8710
166 26174
83 26395
12 79364
580 8784
60 26408
183 26168
13 79628
95 26269
14 79416
20 79323
1 236408
617 796
752 2...

result:

ok 1000000 lines

Test #9:

score: 0
Accepted
time: 281ms
memory: 253460kb

input:

1000000
1011111110111111111101011001101101010110101011111011111101101011101011110101010110101111110011111111111111110101111111101111111110110111000011110111111101110111111111111110011100111111011011111011001101111111010011011000011011110011011010111110110101111111110011101111001111001111110101011111...

output:

1 749803
8 187706
2 562095
20 46853
15 140852
13 140526
2 421565
119 11681
73 35171
15 35308
12 105543
137 35148
10 105375
8 105233
2 316323
168 2981
367 8699
688 8902
127 26266
154 8789
4 26515
14 26628
7 78911
682 8723
126 26421
12 26492
8 78878
132 26393
8 78837
4 78727
13 237587
3371 733
358 224...

result:

ok 1000000 lines

Test #10:

score: 0
Accepted
time: 267ms
memory: 253176kb

input:

1000000
0111111010111111111111011001111111111101010111110011111011111111111011111111110101111101111111010001111101111111011111111111111111111011001011111011011111111111110101110110111110111100111111011011101111111101111111101111011110110111101111011011110101110010000100110110111111111101111111101111...

output:

2 749371
6 187938
2 561431
20 46844
4 141093
13 141010
2 420417
79 11857
31 34986
21 35089
21 106002
102 35252
25 105755
32 105334
2 315077
206 2993
341 8863
203 8839
133 26144
272 8652
37 26436
91 26796
40 79201
493 8930
214 26318
77 26330
42 79420
207 26170
42 79154
44 79055
2 236017
1164 762
717 ...

result:

ok 1000000 lines

Test #11:

score: 0
Accepted
time: 329ms
memory: 255516kb

input:

1000000
1111110111111010110010101100011010111110010101111101111100000110101111111101111011100010011010101110111100110111100100011101111111111100100001010000101111111101101111100011110110011011101011011111010111111001101011110111101111001111110100111101101010111101111100011111101001110011111100110111...

output:

1 666195
5 222341
1 443852
13 74166
8 148174
6 148105
1 295743
9 24732
18 49433
4 49600
8 98571
22 49568
5 98534
3 98437
5 197297
88 8250
9 16481
59 16487
33 32946
73 16434
3 33163
79 32977
6 65589
18 16488
29 33079
14 33185
3 65343
21 32892
3 65540
1 65788
15 131502
192 2811
20 5438
281 5391
32 110...

result:

ok 1000000 lines

Test #12:

score: 0
Accepted
time: 398ms
memory: 243744kb

input:

1000000
0001110001000011100010011010000011100101101101101000000110110111011000111100110011101110100011011010100011100011010101001110000111010100001000000010111100010101000001101111111111100100001000000011111110111111101010000100111010000000000111001101010110010011010111100001011101001100111000110101...

output:

4 499935
5 250197
12 249736
4 125030
17 125167
23 124759
48 124973
4 62402
9 62627
14 62817
15 62347
29 62192
16 62563
31 62360
104 62611
5 31241
21 31158
120 31499
23 31125
27 31331
18 31485
18 31175
88 31169
31 30826
143 31361
21 31370
101 31187
36 31107
17 31248
71 31180
81 31422
9 15723
22 15516...

result:

ok 1000000 lines

Test #13:

score: 0
Accepted
time: 335ms
memory: 254680kb

input:

1000000
1010101110000001110110111111100111100111110110011110101011011101011101011111011001011000111101110111100111001111011100110111001110111001111010001110110111011111100001001011111000011100100001001011011110111111100110010101101101010100111010000101111100101111001110111001101000111111001111110110...

output:

1 666289
2 222169
4 444118
4 73988
10 148179
9 147923
8 296191
2 24935
8 49053
26 49473
17 98704
9 49089
17 98831
10 98748
4 197435
112 8320
36 16614
30 16292
42 32758
75 16635
13 32836
73 32866
5 65835
85 16512
31 32572
8 32982
11 65845
25 32625
11 66115
9 65951
6 131481
174 2819
56 5499
350 5626
1...

result:

ok 1000000 lines

Test #14:

score: 0
Accepted
time: 321ms
memory: 255992kb

input:

1000000
1001111111111101111011011110110111111111101101100001110011101001111011001111111001111110100111001111110001101110111111011111110000011011010101111110101011011001011110101111111101101101100110110110110100110111101011111111111001101110110101111111110101111111110001111111010111010010111111111101...

output:

1 667204
13 222002
3 445201
42 73822
14 148179
13 148031
3 297166
85 24497
32 49325
38 49156
13 99022
28 49295
11 98733
17 98905
3 198254
77 8348
204 16147
103 16527
25 32795
37 16337
72 32818
14 32865
17 66152
210 16281
18 33009
53 32728
32 65999
22 33092
25 65806
26 66182
3 132069
206 2753
411 559...

result:

ok 1000000 lines

Test #15:

score: 0
Accepted
time: 396ms
memory: 258968kb

input:

1000000
0010101010011000000101000001010000000011001010100100101000001010000001001100010110011001111011001100000011001000011000100011001000011100011000000000110101100001011010100101000001100000000000110100010010000000010101000001011110010101101010110010001000001001001010000100000100100100000110100111...

output:

3 333954
4 222169
9 111784
6 148128
12 74037
28 74370
74 37413
4 98576
29 49550
13 49389
52 24646
47 49673
112 24694
95 24826
177 12585
29 65565
23 33010
41 32950
42 16595
25 32877
93 16507
151 16532
248 8109
35 33017
38 16651
106 16526
478 8164
205 16618
191 8204
443 8374
642 4208
21 43930
69 21631...

result:

ok 1000000 lines

Test #16:

score: 0
Accepted
time: 377ms
memory: 257896kb

input:

1000000
0001001110100100100001001001000100010000110000000100000000000101000000000010111000001010111000110101000100110111010000100000100000011010011000010001010010101101011000000001110111001000010010001001001000010001000010001100010100010000110110101001001010100011000000010100100010000000100000000000...

output:

4 333034
8 222243
6 110790
6 148114
54 74128
33 74184
63 36604
9 98727
10 49383
60 49532
79 24593
61 49564
62 24617
131 24460
249 12141
6 65826
7 32900
50 32838
52 16543
72 32993
87 16535
89 16562
459 8028
72 33073
92 16487
146 16485
270 8125
504 16395
398 8060
546 8148
723 3990
10 44001
47 21823
61...

result:

ok 1000000 lines

Test #17:

score: 0
Accepted
time: 397ms
memory: 258380kb

input:

1000000
0000000000000010100100001111000100000010111100010110111100000001001010100100001110000010010010000010001000000100100111000101000100000001000010100111101010000000111010011010000110010001000010000001000011110001100010011111000011100010101010100001100110110001011000010001000010000001101100000010...

output:

15 333427
16 222077
22 111349
17 147864
31 74212
19 74011
28 37335
21 98651
43 49209
44 49302
27 24908
30 49365
111 24643
42 24794
156 12536
29 65655
28 32994
36 32900
57 16307
61 32821
157 16479
170 16526
256 8380
134 32954
106 16406
80 16373
181 8268
129 16528
86 8262
244 8331
303 4201
37 43968
51...

result:

ok 1000000 lines

Test #18:

score: 0
Accepted
time: 364ms
memory: 261100kb

input:

1000000
0001100110000010011011001001101101011000101101000010110000000000000001001100100000000110010110001001001000000000010101100101001000100111000100010010000000010000110001001011101010000001001000000101000110000010011000000000000101100100000010100001000000110101100000111010000010010000001001010000...

output:

4 332903
4 222115
5 110787
10 148255
11 73858
10 74035
120 36750
23 98787
11 49465
14 49269
11 24587
23 49711
13 24319
130 24553
557 12196
11 65837
50 32949
31 32839
147 16623
42 32864
56 16404
149 16446
382 8134
95 32981
38 16724
161 16173
300 8141
214 16409
168 8141
518 8197
922 3998
12 43979
79 2...

result:

ok 1000000 lines

Test #19:

score: -100
Wrong Answer
time: 367ms
memory: 249784kb

input:

1000000
0010101111101111000111111000011000001110000001101111111001011110100010010011110011011000100011111100111110000110100111101111100100010010001001101110000011101110000001111001100111111001010111011101110101010110110111101011000011100111100110000001111111111000111111011111000111111001100010010101...

output:

3 560179
4 234053
4 326124
11 109938
6 124115
6 137301
4 188818
8 50553
34 59384
38 50337
7 73777
5 65008
17 72291
8 85906
13 102903
4 23790
31 26760
12 25095
13 34289
18 23286
110 27051
8 27289
12 46486
20 29165
8 35839
16 28593
19 43695
12 41970
44 43929
13 49905
57 52988
33 11374
85 12414
14 1118...

result:

wrong answer 128959th lines differ - expected: '2727 147', found: '2727 146'