QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#380347#6670. Nizltunjic#33 211ms27380kbC++141.3kb2024-04-07 00:59:082024-07-04 03:33:31

Judging History

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

  • [2024-07-04 03:33:31]
  • 评测
  • 测评结果:33
  • 用时:211ms
  • 内存:27380kb
  • [2024-04-07 00:59:08]
  • 提交

answer

#include <cstdio> 
#include <chrono> 
#include <random> 
#include <cstring> 
#include <algorithm>

using namespace std;

typedef long long ll; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 

const int N = 1e6 + 10;
const int OG = 5000;

int n, A[N];
int R[N], P[N]; 

int U[N], S[N], I[N]; 
int trazi(int u) { return U[u] == -1 ? u : U[u] = trazi(U[u]); } 
void unija(int u, int v) {
	u = trazi(u); 
	v = trazi(v); 
	if(S[u] < S[v]) swap(u, v); 
	U[v] = u;
	S[u] += S[v];
}

int main() {
	for(int i = 1; i < N; ++i) {
		R[i] = rng();
		P[i] = P[i - 1] ^ R[i];
	}

	scanf("%d", &n); 
	ll ans = 0;
	for(int i = 0; i < n; ++i) {
		scanf("%d", A + i); 
		I[i] = i;
		if(n > OG) continue;
		int res = 0;
		for(int j = i; j >= 0; --j) {
			res ^= R[A[j]];
			ans += (res == P[i - j + 1]);
		}
	}

	if(n <= OG) {
		printf("%lld\n", ans);
		return 0;
	}

	memset(U, -1, sizeof(U));
	sort(I, I + n, [](int a, int b) { return A[a] < A[b]; });
	for(int i = 0; i < n; ++i) {
		int ind = I[i]; 
		S[ind] = 1;
		if(ind != 0 && S[trazi(ind - 1)] > 0) unija(ind - 1, ind);
		if(ind != n - 1 && S[trazi(ind + 1)] > 0) unija(ind, ind + 1); 
		ans += S[trazi(ind)] == i + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

详细

Subtask #1:

score: 13
Accepted

Test #1:

score: 13
Accepted
time: 77ms
memory: 27308kb

input:

998929
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

998929

result:

ok single line: '998929'

Test #2:

score: 0
Accepted
time: 72ms
memory: 27352kb

input:

990763
990763 990762 990761 990760 990759 990758 990757 990756 990755 990754 990753 990752 990751 990750 990749 990748 990747 990746 990745 990744 990743 990742 990741 990740 990739 990738 990737 990736 990735 990734 990733 990732 990731 990730 990729 990728 990727 990726 990725 990724 990723 990722...

output:

990763

result:

ok single line: '990763'

Test #3:

score: 0
Accepted
time: 211ms
memory: 27380kb

input:

998735
988140 666830 849895 510099 129658 604780 86344 583384 917331 770372 686521 542162 601112 972325 197506 642976 589646 677694 962319 902036 770622 373945 329490 459023 981810 280818 863168 231417 427339 191541 853228 893599 321387 119939 713001 138836 170434 822971 966309 553875 399252 294428 ...

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 127ms
memory: 27332kb

input:

991802
495901 495900 495899 495898 495897 495896 495895 495894 495893 495892 495891 495890 495889 495888 495887 495886 495885 495884 495883 495882 495881 495880 495879 495878 495877 495876 495875 495874 495873 495872 495871 495870 495869 495868 495867 495866 495865 495864 495863 495862 495861 495860...

output:

991802

result:

ok single line: '991802'

Test #5:

score: 0
Accepted
time: 122ms
memory: 27360kb

input:

991541
155561 90787 79050 102012 302337 425258 434631 156967 95806 390981 11852 438211 136965 331050 223485 319359 65254 129022 228172 335927 252877 88447 242710 215447 157160 257148 421902 439303 93618 343574 318048 490244 125166 201632 177193 397493 237454 166715 38324 237791 225567 7503 428805 20...

output:

495773

result:

ok single line: '495773'

Test #6:

score: 0
Accepted
time: 67ms
memory: 27376kb

input:

997777
997777 997776 997775 997774 997773 997772 997771 997770 997769 997768 997767 997766 997765 997764 997763 997762 997761 997760 997759 997758 997757 997756 997755 997754 997753 997752 997751 997750 997749 997748 997747 997746 997745 997744 997743 997742 997741 997740 997739 997738 997737 997736...

output:

997777

result:

ok single line: '997777'

Test #7:

score: 0
Accepted
time: 117ms
memory: 27172kb

input:

995139
995139 995138 995137 995136 995135 995134 995133 995132 995131 995130 995129 995128 995127 995126 995125 995124 995123 995122 995121 995120 995119 995118 995117 995116 995115 995114 995113 995112 995111 995110 995109 995108 995107 995106 995105 995104 995103 995102 995101 995100 995099 995098...

output:

497572

result:

ok single line: '497572'

Test #8:

score: 0
Accepted
time: 144ms
memory: 27356kb

input:

992233
992233 992232 992230 992228 992227 992226 992223 992221 992219 992216 992215 992214 992213 992212 992210 992209 992208 992207 992206 992203 992201 992200 992197 992196 992190 992189 992188 992186 992185 992182 992180 992179 992177 992175 992174 992172 992171 992170 992169 992167 992166 992163...

output:

992233

result:

ok single line: '992233'

Test #9:

score: 0
Accepted
time: 107ms
memory: 27276kb

input:

992946
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

92622

result:

ok single line: '92622'

Test #10:

score: 0
Accepted
time: 114ms
memory: 27376kb

input:

996504
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

23522

result:

ok single line: '23522'

Test #11:

score: 0
Accepted
time: 93ms
memory: 27352kb

input:

990975
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

25159

result:

ok single line: '25159'

Test #12:

score: 0
Accepted
time: 5ms
memory: 12192kb

input:

1
1

output:

1

result:

ok single line: '1'

Subtask #2:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 15ms
memory: 12652kb

input:

4977
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

4977

result:

ok single line: '4977'

Test #14:

score: 0
Accepted
time: 15ms
memory: 13008kb

input:

4971
2 2 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 2 1 1 2 2 2 1 1 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 2 2 2 1 2 1 1 1 1 2 2 1 2 1 2 2 1 2 1 2 1 1 1 2 2 2 1 1 1 2 2 2 2 2 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 2 1 1 2 2 1 2 1 1 1 2 1 2 2 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 1...

output:

4921

result:

ok single line: '4921'

Test #15:

score: 0
Accepted
time: 7ms
memory: 11996kb

input:

4972
2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...

output:

7457

result:

ok single line: '7457'

Test #16:

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

input:

4978
1 8 9 3 2 6 6 9 5 9 1 2 1 3 3 1 1 5 7 1 2 5 5 7 3 3 4 7 5 6 10 1 8 6 10 3 5 5 6 3 4 7 6 5 3 2 5 6 8 8 9 4 3 3 9 4 8 10 1 10 2 7 4 10 9 9 4 4 5 1 5 7 8 6 8 4 1 3 4 5 6 5 8 3 7 3 3 5 7 9 7 6 9 3 9 3 4 5 1 3 8 3 1 6 9 1 7 5 5 4 4 8 6 8 5 7 9 7 4 4 9 7 5 4 6 6 9 4 6 5 2 1 4 3 9 10 4 3 1 7 5 7 1 8 6...

output:

653

result:

ok single line: '653'

Test #17:

score: 0
Accepted
time: 14ms
memory: 12604kb

input:

4999
91 55 18 98 86 72 61 70 60 22 15 98 23 1 70 26 91 44 64 78 1 20 58 87 37 99 61 17 40 60 82 1 62 39 27 5 65 96 82 44 2 95 4 79 95 87 45 18 45 8 7 61 18 17 87 74 85 41 93 53 88 94 84 53 27 11 4 16 23 55 22 53 19 64 32 41 25 65 38 40 64 63 23 77 14 18 58 38 36 51 47 69 36 26 9 56 26 63 5 90 93 37 ...

output:

40

result:

ok single line: '40'

Test #18:

score: 0
Accepted
time: 7ms
memory: 13560kb

input:

4961
56 871 832 207 364 919 980 489 90 612 397 766 355 519 487 297 991 188 809 81 650 739 820 442 243 159 765 880 111 275 205 415 120 297 878 629 524 580 493 600 732 266 15 285 94 254 827 328 834 145 893 166 959 964 562 961 91 189 996 25 478 205 685 700 844 780 617 23 564 578 369 2 691 516 817 640 9...

output:

3

result:

ok single line: '3'

Test #19:

score: 0
Accepted
time: 12ms
memory: 13116kb

input:

4995
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

4995

result:

ok single line: '4995'

Test #20:

score: 0
Accepted
time: 11ms
memory: 12352kb

input:

4953
4953 4952 4951 4950 4949 4948 4947 4946 4945 4944 4943 4942 4941 4940 4939 4938 4937 4936 4935 4934 4933 4932 4931 4930 4929 4928 4927 4926 4925 4924 4923 4922 4921 4920 4919 4918 4917 4916 4915 4914 4913 4912 4911 4910 4909 4908 4907 4906 4905 4904 4903 4902 4901 4900 4899 4898 4897 4896 4895 ...

output:

4953

result:

ok single line: '4953'

Test #21:

score: 0
Accepted
time: 11ms
memory: 13516kb

input:

4994
2576 2750 4180 2695 4302 4893 397 4522 1471 1131 1844 1578 3865 4104 282 1290 2729 2139 1860 2542 4012 4233 882 2915 65 4547 3283 3976 1661 605 1862 3902 3524 2368 4822 21 1575 3587 3762 515 560 170 3554 2589 3205 3517 4262 1659 3170 1646 609 3922 2507 2546 2171 4946 755 4932 1248 2634 3017 309...

output:

2

result:

ok single line: '2'

Test #22:

score: 0
Accepted
time: 15ms
memory: 13148kb

input:

4950
2475 2474 2473 2472 2471 2470 2469 2468 2467 2466 2465 2464 2463 2462 2461 2460 2459 2458 2457 2456 2455 2454 2453 2452 2451 2450 2449 2448 2447 2446 2445 2444 2443 2442 2441 2440 2439 2438 2437 2436 2435 2434 2433 2432 2431 2430 2429 2428 2427 2426 2425 2424 2423 2422 2421 2420 2419 2418 2417 ...

output:

4950

result:

ok single line: '4950'

Test #23:

score: 0
Accepted
time: 11ms
memory: 12496kb

input:

4989
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

4990

result:

ok single line: '4990'

Test #24:

score: 0
Accepted
time: 15ms
memory: 12944kb

input:

4959
2479 2478 2477 2476 2475 2474 2473 2472 2471 2470 2469 2468 2467 2466 2465 2464 2463 2462 2461 2460 2459 2458 2457 2456 2455 2454 2453 2452 2451 2450 2449 2448 2447 2446 2445 2444 2443 2442 2441 2440 2439 2438 2437 2436 2435 2434 2433 2432 2431 2430 2429 2428 2427 2426 2425 2424 2423 2422 2421 ...

output:

4959

result:

ok single line: '4959'

Test #25:

score: 0
Accepted
time: 11ms
memory: 11928kb

input:

4957
1707 544 969 1762 1776 1369 1806 1848 2314 634 407 1653 240 628 211 2133 57 946 455 254 1993 557 272 277 111 52 961 1903 1164 671 348 1368 861 2332 1858 127 1385 89 2043 369 2184 1582 789 581 825 1942 1596 1973 890 268 312 1902 179 48 1043 2284 1244 2151 1795 1710 1468 75 1257 624 1450 1149 864...

output:

2481

result:

ok single line: '2481'

Test #26:

score: 0
Accepted
time: 7ms
memory: 13836kb

input:

4989
4989 4988 4987 4986 4985 4984 4983 4982 4981 4980 4979 4978 4977 4976 4975 4974 4973 4972 4971 4970 4969 4968 4967 4966 4965 4964 4963 4962 4961 4960 4959 4958 4957 4956 4955 4954 4953 4952 4951 4950 4949 4948 4947 4946 4945 4944 4943 4942 4941 4940 4939 4938 4937 4936 4935 4934 4933 4932 4931 ...

output:

4989

result:

ok single line: '4989'

Test #27:

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

input:

4976
4976 4975 4974 4973 4972 4971 4970 4969 4968 4967 4966 4965 4964 4963 4962 4961 4960 4959 4958 4957 4956 4955 4954 4953 4952 4951 4950 4949 4948 4947 4946 4945 4944 4943 4942 4941 4940 4939 4938 4937 4936 4935 4934 4933 4932 4931 4930 4929 4928 4927 4926 4925 4924 4923 4922 4921 4920 4919 4918 ...

output:

2490

result:

ok single line: '2490'

Test #28:

score: 0
Accepted
time: 16ms
memory: 13648kb

input:

4993
4063 895 2954 273 556 1806 4088 1376 4627 2647 126 1529 4106 1521 3595 559 1060 1249 4357 4582 164 1320 2508 3585 2752 4323 4916 4030 2110 1053 4163 836 3525 235 3869 198 584 1001 1817 4986 4112 1862 1295 3798 438 2365 4809 2546 1368 4719 1140 548 2386 2323 1730 708 1850 2689 3637 1494 1751 268...

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 14ms
memory: 12256kb

input:

4961
4961 4959 4957 4956 4954 4950 4948 4943 4941 4938 4937 4934 4933 4931 4925 4923 4922 4920 4919 4918 4915 4910 4908 4906 4905 4904 4900 4899 4892 4891 4889 4888 4887 4886 4884 4883 4881 4876 4875 4873 4872 4871 4868 4867 4864 4863 4861 4859 4857 4856 4850 4848 4846 4844 4839 4838 4836 4834 4833 ...

output:

4961

result:

ok single line: '4961'

Test #30:

score: 0
Accepted
time: 15ms
memory: 13224kb

input:

4965
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

464

result:

ok single line: '464'

Test #31:

score: 0
Accepted
time: 11ms
memory: 12684kb

input:

4983
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 1462 1461 1460 1459 1458 1457 1456 1455 1454 1453 1452 1451 1450 1449 1448 1447 1446 1445 1444 1443 1442 1441 1440 1439 1438 1437 143...

output:

119

result:

ok single line: '119'

Test #32:

score: 0
Accepted
time: 11ms
memory: 12164kb

input:

4954
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4868 4867 4866 4865 4864 4863 4862 4861 4860 4859 4858 4857 4856 4855 4854 4853 4852 4851 4850 4849 4848 4847 4846 4845 4844 4843 4842 4841 4840 4839 4838 4837 4836 4835 4834 4833 4832...

output:

127

result:

ok single line: '127'

Test #33:

score: 0
Accepted
time: 11ms
memory: 11872kb

input:

4979
4419 4470 4753 4439 4742 4063 3095 179 3189 3445 4733 1886 3351 2582 206 3276 4191 966 4066 1356 3897 3578 3661 3899 2377 4234 4313 3860 1571 183 4514 582 7 3741 2866 1192 2363 1269 1355 4271 1337 4729 4915 2797 4630 891 921 3836 2258 2452 2228 3144 1260 4180 4353 2296 1439 2480 1591 3383 2868 ...

output:

1

result:

ok single line: '1'

Test #34:

score: 0
Accepted
time: 11ms
memory: 13556kb

input:

4952
3958 1432 3367 3571 180 108 4713 1020 3455 252 777 1497 4191 3288 1686 1526 4083 2890 866 345 2293 4296 489 660 3821 883 1859 2456 2109 4278 4789 3759 1397 4806 2883 3761 2474 1903 1442 2024 2823 3533 4337 1341 4588 4230 4739 4522 1450 3768 1152 2559 1323 832 422 1480 3719 1407 1909 1621 3005 2...

output:

0

result:

ok single line: '0'

Test #35:

score: 0
Accepted
time: 9ms
memory: 12256kb

input:

4960
3482 2390 3624 2086 3162 4262 3869 849 4200 1681 4431 1342 1164 3428 57 1094 2302 4028 3979 53 763 2784 553 4037 442 3696 4311 938 2193 31 640 3830 1695 4751 2018 3482 2 1476 4369 3810 4692 3414 4638 1921 278 3052 478 2121 4397 2899 1977 3486 4733 556 3693 4580 3857 4905 4605 3360 4664 3945 271...

output:

1

result:

ok single line: '1'

Test #36:

score: 0
Accepted
time: 0ms
memory: 13644kb

input:

1
1

output:

1

result:

ok single line: '1'

Subtask #3:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #37:

score: 0
Wrong Answer
time: 3ms
memory: 20368kb

input:

49774
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

25

result:

wrong answer 1st lines differ - expected: '49774', found: '25'

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%