QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#778658 | #9231. Random Numbers | taijinvjin | WA | 299ms | 4748kb | C++17 | 1.1kb | 2024-11-24 15:38:18 | 2024-11-24 15:38:19 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n + 1);
for (int i = 1; i <= n; i ++) {
std::cin >> a[i];
a[i] += a[i - 1];
}
int Ans = 0;
int R1 = std::min(n, 1000LL);
int R2 = std::max(R1 + 1, n - 1000);
for (int i = 1; i <= R1; i ++) {
for (int r = i; r <= n; r ++) {
if (a[r] - a[r - i] == i * i) {
Ans ++;
}
}
}
for (int i = R2; i <= n; i ++) {
for (int r = i; r <= n; r ++) {
if (a[r] - a[r - i] == i * i) {
Ans ++;
}
}
}
for (int i = std::max(R1 + 1, n / 2 - 1000); i <= std::min(n / 2 + 1000, R2); i ++) {
for (int r = i; r <= n; r ++) {
if (a[r] - a[r - i] == i * i) {
Ans ++;
}
}
}
std::cout << Ans << "\n";
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while (T --) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
2 3 2 1 3 5 3 4 2 5 1
output:
2 2
result:
ok 2 number(s): "2 2"
Test #2:
score: 0
Accepted
time: 285ms
memory: 3856kb
input:
32 9811 3756 4960 5623 8471 9330 2388 7066 5434 4707 1711 2109 7274 9630 5057 6390 3252 2632 2291 4697 1923 6423 369 2430 2586 549 1344 1518 9170 268 1315 8808 4843 4603 532 2210 275 835 9059 8529 3449 1412 6071 6737 6944 788 8202 6684 6926 1729 7530 6506 9781 5523 5864 7067 9398 3446 2044 2578 2530...
output:
2 1 1 3 1 4 2 2 2 1 3 2 3 4 2 3 1 1 2 2 2 2 2 1 1 2 1 1 3 2 1 1
result:
ok 32 numbers
Test #3:
score: 0
Accepted
time: 296ms
memory: 4616kb
input:
30 197277 196178 84300 27937 106346 19833 131659 146010 164112 125344 93600 5183 26597 55011 30797 100914 95876 43674 164981 46730 54589 170497 74527 174820 95270 4993 78003 192129 55163 191465 156865 7654 164216 22085 118048 86126 178144 77067 60852 180286 180626 3165 43878 111790 131714 96251 9864...
output:
3 2 4 3 1 1 2 1 1 1 2 2 4 2 2 1 3 2 3 5 2 2 2 3 1 2 2 3 3 3
result:
ok 30 numbers
Test #4:
score: 0
Accepted
time: 295ms
memory: 4748kb
input:
1 200000 137314 193717 79689 175047 84798 4387 143791 85750 74947 54899 184128 11640 65653 28078 162472 26557 67059 131134 76117 106373 112748 129954 162927 153580 108335 90723 55445 10637 129723 50828 49548 181363 173509 114849 139837 78161 184622 85313 149952 137930 3981 20555 35145 188575 101906 ...
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 135ms
memory: 3608kb
input:
133 1614 1272 303 1151 1402 1380 1564 1048 654 1493 994 1243 972 1437 617 940 458 1220 1597 889 60 3 1420 478 1396 905 528 332 1552 45 1548 503 703 1070 2 770 1413 472 400 1011 584 771 542 1588 1529 566 1467 364 216 835 1035 1462 555 1503 1001 304 378 762 732 948 476 10 799 908 620 295 249 439 718 9...
output:
2 3 2 2 2 2 1 1 2 2 2 1 1 2 1 1 2 2 3 2 2 1 3 2 2 3 2 1 1 3 1 1 2 3 1 3 1 1 1 1 1 1 3 6 6 3 2 1 1 2 2 3 2 3 3 3 2 1 1 3 1 1 2 2 3 1 2 2 1 3 2 4 4 2 2 2 1 1 3 2 2 2 3 3 1 1 1 2 1 3 1 2 2 3 4 6 2 1 4 3 1 2 2 2 1 1 1 2 2 1 2 2 2 2 3 3 1 1 1 1 3 1 2 3 2 1 3 2 2 4 3 1 3
result:
ok 133 numbers
Test #6:
score: 0
Accepted
time: 134ms
memory: 3556kb
input:
135 1434 226 580 497 715 1367 589 298 216 1027 982 1307 231 306 1084 627 752 490 684 481 500 354 1346 1353 1028 473 457 991 1283 264 235 1045 1308 970 209 971 1197 1191 204 572 735 1280 1246 523 1103 384 757 1272 639 618 1372 50 16 335 599 1219 1284 449 840 1140 416 91 1407 868 1420 317 1385 119 170...
output:
4 1 2 2 3 2 3 3 2 2 2 2 1 1 1 2 1 1 1 4 1 2 2 2 3 2 1 2 1 2 1 4 1 1 1 2 2 4 3 1 1 1 2 3 1 1 1 3 1 1 1 2 2 3 1 2 1 2 1 3 2 1 1 1 3 1 2 2 1 2 2 4 2 1 2 1 2 2 1 3 2 1 2 2 2 2 3 1 2 1 1 2 1 4 1 3 2 1 2 2 1 3 2 1 3 1 1 1 3 1 2 1 2 1 2 2 3 1 2 2 2 1 1 1 1 2 2 2 2 1 2 2 1 4 3
result:
ok 135 numbers
Test #7:
score: 0
Accepted
time: 129ms
memory: 3568kb
input:
138 1852 41 1044 775 469 513 1590 1151 582 1213 43 270 505 774 1845 1050 626 704 1491 1832 600 95 1131 1176 1144 663 831 1757 373 62 748 936 1026 1090 1784 1014 370 901 675 100 635 1147 1088 1162 495 1029 891 1173 511 828 1604 570 637 1313 641 18 906 1186 256 946 1314 607 1596 1243 523 1225 863 970 ...
output:
1 2 3 2 1 2 2 2 2 1 5 2 2 2 1 4 2 2 1 3 3 1 2 3 3 2 1 1 1 2 2 1 2 2 1 5 4 3 3 2 2 2 2 5 2 1 2 5 1 2 2 2 3 4 2 1 3 2 1 2 4 2 3 2 3 1 3 3 2 1 3 3 1 1 4 2 2 2 2 3 2 3 1 4 2 3 2 1 2 1 2 3 4 1 5 3 1 1 3 2 3 2 1 5 4 5 2 1 4 3 1 1 2 1 4 4 1 3 3 1 1 5 3 3 3 2 2 1 3 2 1 2 1 1 1 2 2 3
result:
ok 138 numbers
Test #8:
score: 0
Accepted
time: 137ms
memory: 3644kb
input:
134 1471 1079 1269 675 699 1048 786 553 1378 1466 1152 867 302 1252 1441 563 1415 339 279 404 392 1400 614 983 908 760 1281 120 1233 818 1045 609 1454 248 1345 1023 638 826 913 1267 28 1024 988 2 1329 68 903 1195 1361 445 380 1451 1304 200 333 258 1167 1215 837 1238 641 1251 1113 59 899 1244 1138 10...
output:
1 2 1 2 1 1 4 1 2 5 2 2 1 3 2 1 1 2 1 2 1 1 1 5 1 2 1 2 4 2 1 2 1 1 2 1 1 1 1 1 1 3 1 3 2 2 2 2 1 1 2 1 1 4 2 1 2 5 3 2 3 1 1 1 1 1 2 1 3 2 2 2 3 2 3 4 1 2 1 4 2 4 3 3 3 1 2 2 1 1 2 1 2 3 2 1 2 3 2 2 2 3 1 3 1 2 2 3 2 2 1 1 4 2 3 3 2 1 1 1 1 1 1 2 2 1 4 3 2 2 1 1 1 1
result:
ok 134 numbers
Test #9:
score: 0
Accepted
time: 278ms
memory: 3604kb
input:
33 9856 7566 821 5762 1554 8101 9042 432 6381 9463 2815 3571 7995 9773 2193 8067 2819 7267 2467 911 5737 4875 8392 4307 2584 3462 4080 2587 2967 701 8611 4353 6638 9758 1163 4830 7974 171 7301 2183 3044 8725 7318 989 8716 5532 7341 5732 4571 9573 8344 3666 9842 7464 696 5569 6145 7225 5801 7796 4256...
output:
2 4 2 4 1 1 2 2 3 1 4 2 3 1 1 3 1 2 1 2 1 1 1 3 1 1 2 3 2 3 1 1 2
result:
ok 33 numbers
Test #10:
score: 0
Accepted
time: 285ms
memory: 4360kb
input:
6 155123 106491 99516 65958 59315 151234 36554 110949 8864 61761 121755 48512 132793 3382 92819 11147 151672 96972 76359 119950 54177 19251 152364 124264 38277 1045 141461 634 58907 89119 14734 139215 97488 91683 34075 20060 6389 112125 77813 149172 34413 67548 21350 72560 93506 120224 46941 132989 ...
output:
3 1 2 3 1 2
result:
ok 6 numbers
Test #11:
score: 0
Accepted
time: 299ms
memory: 4588kb
input:
1 199222 3425 46445 156584 50078 30853 2422 8714 193754 96677 55786 159316 483 149336 176525 128768 177013 106651 1710 172121 158124 186112 35124 1944 80400 177836 74721 69576 183171 183848 26754 96915 191373 138575 160798 67628 95875 180184 132190 162402 116531 35624 64528 153009 81779 153799 3485 ...
output:
3
result:
ok 1 number(s): "3"
Test #12:
score: 0
Accepted
time: 137ms
memory: 3544kb
input:
129 1525 1493 1286 1393 588 1062 84 1050 1369 132 332 647 644 372 912 1390 909 1430 551 385 14 656 877 161 781 928 310 1221 943 991 146 209 154 94 220 1357 140 1456 884 325 1492 1323 1027 543 1522 410 417 1211 555 12 1015 241 1382 1035 1170 1163 1199 721 11 579 1250 1337 688 366 820 156 713 911 102 ...
output:
3 3 2 6 1 3 2 2 1 3 2 2 4 1 2 2 4 2 2 2 1 2 1 3 2 3 2 3 2 1 2 3 1 5 2 3 1 1 3 5 2 2 1 1 2 2 1 1 2 2 3 1 3 2 2 1 1 4 3 1 1 2 3 2 3 1 1 3 2 1 2 2 1 2 1 1 1 2 1 2 3 1 1 2 2 1 2 1 1 3 3 1 1 3 2 2 2 1 2 1 2 1 3 4 2 1 1 1 2 2 3 2 3 1 5 3 2 3 1 3 2 3 1 1 1 2 2 1 3
result:
ok 129 numbers
Test #13:
score: 0
Accepted
time: 24ms
memory: 3636kb
input:
1070 152 33 98 73 38 44 127 7 79 43 134 55 50 111 83 68 89 91 64 88 51 124 138 104 67 15 36 75 26 12 31 72 141 117 110 112 137 152 74 85 120 23 121 41 129 119 18 52 16 87 139 34 146 69 140 115 147 100 114 14 145 1 103 3 86 99 24 130 105 13 30 54 25 92 113 59 56 22 136 58 93 84 29 8 106 28 39 78 57 2...
output:
3 1 2 1 2 2 1 5 1 1 1 2 2 2 1 1 1 2 1 2 2 2 1 2 3 4 2 1 1 1 1 2 1 1 1 1 3 1 2 2 1 1 1 1 2 3 2 2 1 3 3 3 1 1 4 2 2 1 3 2 2 2 1 2 2 1 1 1 1 3 3 2 1 5 1 1 3 1 2 1 2 2 1 2 2 2 3 1 4 1 2 2 2 1 2 1 1 3 1 4 2 1 5 2 2 2 2 1 3 3 2 2 1 1 3 2 1 2 1 1 1 6 3 1 4 2 3 3 2 3 1 2 2 1 2 1 2 4 1 3 2 4 4 2 1 2 3 2 2 1 ...
result:
ok 1070 numbers
Test #14:
score: 0
Accepted
time: 269ms
memory: 3788kb
input:
48 94 64 66 80 35 56 53 74 86 3 14 34 38 2 31 49 43 83 54 13 73 69 71 33 26 41 62 52 82 51 6 9 15 7 25 87 19 77 48 91 23 55 11 17 63 37 59 30 36 84 32 88 39 46 10 4 12 57 22 70 60 20 92 44 16 29 21 89 47 75 90 85 42 67 58 28 65 61 78 8 5 68 45 24 94 72 18 93 50 76 27 1 81 79 40 280 92 55 18 184 58 2...
output:
2 2 1 2 3 1 2 2 2 1 2 4 2 2 2 1 2 2 3 2 2 1 2 1 3 3 3 1 1 1 5 3 1 1 2 2 3 2 3 2 2 2 3 5 1 4 2 2
result:
ok 48 numbers
Test #15:
score: 0
Accepted
time: 289ms
memory: 3904kb
input:
6 20897 16605 6574 6361 18491 19429 1061 16804 11439 10908 18561 11493 11543 7568 1898 4 16020 19984 14632 11046 20373 6914 6474 16312 17112 18822 8903 17488 826 15414 12888 7030 10078 5732 17784 2198 822 20166 17238 7492 12156 2534 15550 15335 12950 20408 18978 15515 20771 1739 7033 20452 2890 1865...
output:
1 1 1 2 3 2
result:
ok 6 numbers
Test #16:
score: 0
Accepted
time: 136ms
memory: 3632kb
input:
135 2622 1182 1033 2308 581 849 2343 1210 1480 1791 708 6 2031 428 557 496 2498 2410 1453 509 1562 102 237 479 953 353 49 1628 110 231 658 1184 2551 1574 1481 84 2262 221 406 1448 804 761 1318 1467 352 1029 657 1862 1301 375 1772 860 405 1637 1279 1604 338 1064 2143 978 46 279 840 408 13 698 829 135...
output:
3 2 1 1 1 3 2 2 2 4 1 1 1 1 1 2 2 2 2 2 2 1 2 1 2 1 2 1 3 2 1 4 3 1 2 2 2 3 3 1 1 3 2 4 1 1 1 2 2 2 1 1 2 2 1 1 2 4 1 4 1 1 1 1 3 1 4 2 1 2 2 2 3 3 3 4 2 2 4 3 4 2 3 1 2 3 2 3 3 2 3 3 3 1 2 3 1 1 2 1 2 2 2 2 2 2 2 1 3 1 1 1 1 3 2 2 1 1 1 2 1 4 2 1 1 3 4 4 1 2 2 4 2 1 1
result:
ok 135 numbers
Test #17:
score: 0
Accepted
time: 154ms
memory: 3780kb
input:
109 1511 1141 55 585 21 1323 190 1 1331 469 317 632 1341 361 1250 492 480 58 1363 1316 828 789 1380 116 169 451 1451 1508 613 936 1478 326 542 579 115 1086 917 3 1378 698 1128 631 1046 1383 696 68 1125 461 617 852 837 591 87 1366 76 675 1490 782 371 385 427 808 1411 1254 94 1247 1087 892 1320 552 79...
output:
2 3 2 3 3 2 1 2 1 1 1 3 3 2 2 2 1 1 4 3 3 3 2 1 2 4 2 1 1 2 1 2 2 1 1 2 2 3 1 3 1 2 3 1 3 1 3 3 2 1 2 1 3 2 2 2 2 1 1 2 3 1 1 2 3 2 5 3 2 2 2 2 2 2 2 1 3 3 2 2 1 1 1 1 2 1 4 3 1 1 1 1 2 2 2 3 2 1 1 1 1 2 1 3 2 2 2 2 4
result:
ok 109 numbers
Test #18:
score: -100
Wrong Answer
time: 141ms
memory: 3644kb
input:
131 2895 1946 164 2546 897 2260 969 112 996 2101 1048 2737 993 2203 76 2372 567 1816 2371 1444 2629 1148 2387 2526 2493 1952 822 412 2584 2813 966 914 2001 2344 1747 1161 1451 10 1007 2678 2599 1056 2312 96 513 1776 1149 2045 2411 900 704 2262 426 838 1049 2374 771 2460 1187 2373 2465 1254 910 2020 ...
output:
1 3 3 2 6 1 1 2 3 2 3 3 3 2 1 1 2 1 1 2 1 2 2 1 2 1 3 3 2 1 3 1 3 2 2 2 2 1 2 5 1 3 2 3 1 1 3 2 2 3 3 1 1 3 4 2 2 2 1 2 1 4 4 2 2 2 1 2 3 3 1 1 2 2 1 2 2 1 2 2 3 3 2 4 3 1 2 2 2 4 2 1 4 5 2 3 1 1 2 1 5 1 1 1 1 1 1 2 3 1 3 1 3 3 2 2 2 1 2 1 2 3 2 3 3 4 1 4 1 2 1
result:
wrong answer 94th numbers differ - expected: '4', found: '5'