QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290232#7967. 二进制daydream#WA 409ms257344kbC++202.1kb2023-12-24 16:27:492023-12-24 16:27:50

Judging History

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

  • [2023-12-24 16:27:50]
  • 评测
  • 测评结果:WA
  • 用时:409ms
  • 内存:257344kb
  • [2023-12-24 16:27:49]
  • 提交

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])
			{
				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: 3604kb

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: 156ms
memory: 245056kb

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: 264ms
memory: 257344kb

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: 280ms
memory: 254856kb

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: 256ms
memory: 256436kb

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: 262ms
memory: 255884kb

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: 322ms
memory: 254032kb

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: 304ms
memory: 255672kb

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: 310ms
memory: 255992kb

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: 307ms
memory: 255824kb

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: 320ms
memory: 255496kb

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: 409ms
memory: 243708kb

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: -100
Wrong Answer
time: 342ms
memory: 255388kb

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:

wrong answer 490743rd lines differ - expected: '-1 0', found: '140111 -1'