UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190234#3312. 圆0x3f100385ms7032kbC++111.4kb2023-10-05 12:05:202023-10-05 12:52:56

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
#define int long long
typedef pair<int, int> PII;
int read() {
	int x = 0;
	char c = getchar();
	while (c < '0' || c > '9') {
		c = getchar();
	}
	while (c >= '0' && c <= '9')
		x = x * 10 + c - '0', c = getchar();
	return x;
}
void write(int x) {
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
void print(int x, char c) { write(x), putchar(c); }
char c[2000010], crr[2000010];
int n, arr[1000010];
signed main() {
#ifndef ONLINE_JUDGE
	freopen("data/data1.in", "r", stdin);
	// freopen("data/data1.out", "w", stdout);
#endif
	scanf("%lld", &n);
	scanf("%s", crr);
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (crr[i] != '0')
			flag = false;
	}
	if (flag) {
		for (int i = 1; i <= n; i++)
			if (i != 1) {
				print((n) * (n - i + 1), '\n');
			} else
				print((n - i + 1) * (n - i + 1), '\n');

		return 0;
	}
	int idx = 0;
	while (crr[idx] == '0') {
		idx++;
	}
	int j = 0;
	for (int i = idx; i < n; i++) {
		c[j++] = crr[i];
	}
	for (int i = j; i < n; i++) {
		c[i] = '0';
	}
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		while (c[i] == '0') {
			i++;
			cnt++;
		}
		arr[1] += cnt * (n);
		for (int j = 2; j <= (cnt + 1) / 2; j++) {
			arr[j] += (cnt + 1 - j - j + 1) * (n - j + 1);
		}
	}
	for (int i = 1; i <= n; i++) {
		print(arr[i], '\n');
	}
	return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1180kb

input:

100
000000000000000000000000001000000000000000010000110000000000000000000000000000000000000000000000...

output:

9600
8910
8232
7760
7296
6840
6392
5952
5520
5278
5040
4806
4576
4350
4128
3910
3696
3486
3280
3078
...

result:

ok 100 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 1180kb

input:

100
111000000000000000001100000000000001111100000000000100000000000000000000000010000000000000000000...

output:

8800
7722
6664
5626
4608
3610
2726
2046
1472
1001
630
267
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100 lines

Test #3:

score: 10
Accepted
time: 0ms
memory: 1176kb

input:

1000
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

966000
930069
897202
865396
839628
814905
790230
765603
741024
716493
693000
672520
654056
635628
61...

result:

ok 1000 lines

Test #4:

score: 10
Accepted
time: 0ms
memory: 1176kb

input:

1000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

968000
939060
914168
889324
864528
841770
819056
796386
773760
751178
730620
710102
689624
669186
64...

result:

ok 1000 lines

Test #5:

score: 10
Accepted
time: 44ms
memory: 5924kb

input:

1000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

999941000000
999877000122
999818000360
999763000702
999708001152
999653001710
999598002376
999543003...

result:

ok 1000000 lines

Test #6:

score: 10
Accepted
time: 42ms
memory: 5104kb

input:

1000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

999945000000
999888000111
999833000330
999778000657
999723001092
999668001635
999613002286
999558003...

result:

ok 1000000 lines

Test #7:

score: 10
Accepted
time: 78ms
memory: 7032kb

input:

1000000
11110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

999996000000
999993000006
999990000016
999987000030
999984000048
999981000070
999978000096
999975000...

result:

ok 1000000 lines

Test #8:

score: 10
Accepted
time: 51ms
memory: 5740kb

input:

1000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

999935000000
999876000123
999817000362
999760000711
999703001172
999646001745
999589002430
999534003...

result:

ok 1000000 lines

Test #9:

score: 10
Accepted
time: 33ms
memory: 5384kb

input:

1000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

999968000000
999945000054
999922000152
999899000294
999876000480
999853000710
999830000984
999807001...

result:

ok 1000000 lines

Test #10:

score: 10
Accepted
time: 137ms
memory: 2148kb

input:

1000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

1000000000000
999999000000
999998000000
999997000000
999996000000
999995000000
999994000000
99999300...

result:

ok 1000000 lines

Extra Test:

score: 0
Extra Test Passed