QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372206 | #7526. Credit Cards | RobeZH# | AC ✓ | 249ms | 54028kb | C++23 | 1.8kb | 2024-03-31 04:45:36 | 2024-03-31 04:45:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define subnb true
#define Lnb true
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
struct P {
int a, b, c;
};
int main() {
// ios::sync_with_stdio(false);
// cin.tie(NULL);
int n;
cin >> n;
int ans = (n - 1) / 3;
if(ans == 0) {
cout << ans << endl;
return 0;
}
n--;
while(n % 3 != 0) n--;
vector<P> res;
int k = n / 3;
int l0 = 2, r0 = k + 1, l1 = k + 2, r1 = n + 1;
// cout << l0 << " " << r0 << " " << l1 << " " << r1 << endl;
// cout << k << endl;
while(true) {
assert((r0 - l0 + 1) * 2 == (r1 - l1 + 1));
if(l0 == r0) {
res.push_back({l0, l1, r1});
// cout << res.back().a << ", " << res.back().b << " " << res.back().c << endl;
break;
}
int m0 = (l0 + r0 + 1) / 2;
int tk = r0 - m0 + 1;
int m1 = r1 - 2 * tk + 1;
rep(i, 0, tk) {
res.push_back({m0 + i, m1 + i, m1 + tk + i});
// cout << res.back().a << ", " << res.back().b << " " << res.back().c << endl;
}
r0 = m0 - 1;
r1 = m1 - 1;
}
cout << sz(res) << '\n';
set<int> S;
for(auto p : res) {
S.insert(p.a);
S.insert(p.b);
S.insert(p.c);
cout << p.a << " " << p.b << " " << p.c << '\n';
assert(1LL * p.a * p.a + 1LL * p.b * p.b < 1LL * p.c * p.c);
assert(p.a + p.b > p.c);
}
assert(sz(S) == 3 * sz(res));
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3524kb
input:
3
output:
0
result:
ok OK 0 triangles!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
4
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
9
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #4:
score: 0
Accepted
time: 249ms
memory: 54028kb
input:
1000000
output:
333333 166668 666667 833334 166669 666668 833335 166670 666669 833336 166671 666670 833337 166672 666671 833338 166673 666672 833339 166674 666673 833340 166675 666674 833341 166676 666675 833342 166677 666676 833343 166678 666677 833344 166679 666678 833345 166680 666679 833346 166681 666680 833347...
result:
ok OK 333333 triangles!
Test #5:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
1
output:
0
result:
ok OK 0 triangles!
Test #6:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
2
output:
0
result:
ok OK 0 triangles!
Test #7:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
5
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #8:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
6
output:
1 2 3 4
result:
ok OK 1 triangles!
Test #9:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
7
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #10:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
8
output:
2 3 6 7 2 4 5
result:
ok OK 2 triangles!
Test #11:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
10
output:
3 3 7 9 4 8 10 2 5 6
result:
ok OK 3 triangles!
Test #12:
score: 0
Accepted
time: 136ms
memory: 34776kb
input:
621316
output:
207105 103554 414211 517764 103555 414212 517765 103556 414213 517766 103557 414214 517767 103558 414215 517768 103559 414216 517769 103560 414217 517770 103561 414218 517771 103562 414219 517772 103563 414220 517773 103564 414221 517774 103565 414222 517775 103566 414223 517776 103567 414224 517777...
result:
ok OK 207105 triangles!
Test #13:
score: 0
Accepted
time: 167ms
memory: 39208kb
input:
713171
output:
237723 118863 475447 594309 118864 475448 594310 118865 475449 594311 118866 475450 594312 118867 475451 594313 118868 475452 594314 118869 475453 594315 118870 475454 594316 118871 475455 594317 118872 475456 594318 118873 475457 594319 118874 475458 594320 118875 475459 594321 118876 475460 594322...
result:
ok OK 237723 triangles!
Test #14:
score: 0
Accepted
time: 187ms
memory: 45016kb
input:
825609
output:
275202 137603 550406 688007 137604 550407 688008 137605 550408 688009 137606 550409 688010 137607 550410 688011 137608 550411 688012 137609 550412 688013 137610 550413 688014 137611 550414 688015 137612 550415 688016 137613 550416 688017 137614 550417 688018 137615 550418 688019 137616 550419 688020...
result:
ok OK 275202 triangles!
Test #15:
score: 0
Accepted
time: 190ms
memory: 42976kb
input:
782282
output:
260760 130382 521522 651902 130383 521523 651903 130384 521524 651904 130385 521525 651905 130386 521526 651906 130387 521527 651907 130388 521528 651908 130389 521529 651909 130390 521530 651910 130391 521531 651911 130392 521532 651912 130393 521533 651913 130394 521534 651914 130395 521535 651915...
result:
ok OK 260760 triangles!
Test #16:
score: 0
Accepted
time: 32ms
memory: 10628kb
input:
148128
output:
49375 24689 98751 123439 24690 98752 123440 24691 98753 123441 24692 98754 123442 24693 98755 123443 24694 98756 123444 24695 98757 123445 24696 98758 123446 24697 98759 123447 24698 98760 123448 24699 98761 123449 24700 98762 123450 24701 98763 123451 24702 98764 123452 24703 98765 123453 24704 987...
result:
ok OK 49375 triangles!
Test #17:
score: 0
Accepted
time: 153ms
memory: 37692kb
input:
681282
output:
227093 113548 454187 567734 113549 454188 567735 113550 454189 567736 113551 454190 567737 113552 454191 567738 113553 454192 567739 113554 454193 567740 113555 454194 567741 113556 454195 567742 113557 454196 567743 113558 454197 567744 113559 454198 567745 113560 454199 567746 113561 454200 567747...
result:
ok OK 227093 triangles!
Test #18:
score: 0
Accepted
time: 192ms
memory: 43664kb
input:
798547
output:
266182 133093 532366 665457 133094 532367 665458 133095 532368 665459 133096 532369 665460 133097 532370 665461 133098 532371 665462 133099 532372 665463 133100 532373 665464 133101 532374 665465 133102 532375 665466 133103 532376 665467 133104 532377 665468 133105 532378 665469 133106 532379 665470...
result:
ok OK 266182 triangles!
Test #19:
score: 0
Accepted
time: 83ms
memory: 20804kb
input:
349290
output:
116429 58216 232859 291074 58217 232860 291075 58218 232861 291076 58219 232862 291077 58220 232863 291078 58221 232864 291079 58222 232865 291080 58223 232866 291081 58224 232867 291082 58225 232868 291083 58226 232869 291084 58227 232870 291085 58228 232871 291086 58229 232872 291087 58230 232873 ...
result:
ok OK 116429 triangles!
Test #20:
score: 0
Accepted
time: 69ms
memory: 19232kb
input:
317275
output:
105758 52881 211518 264397 52882 211519 264398 52883 211520 264399 52884 211521 264400 52885 211522 264401 52886 211523 264402 52887 211524 264403 52888 211525 264404 52889 211526 264405 52890 211527 264406 52891 211528 264407 52892 211529 264408 52893 211530 264409 52894 211531 264410 52895 211532 ...
result:
ok OK 105758 triangles!
Test #21:
score: 0
Accepted
time: 13ms
memory: 8440kb
input:
100000
output:
33333 16668 66667 83334 16669 66668 83335 16670 66669 83336 16671 66670 83337 16672 66671 83338 16673 66672 83339 16674 66673 83340 16675 66674 83341 16676 66675 83342 16677 66676 83343 16678 66677 83344 16679 66678 83345 16680 66679 83346 16681 66680 83347 16682 66681 83348 16683 66682 83349 16684 ...
result:
ok OK 33333 triangles!
Test #22:
score: 0
Accepted
time: 12ms
memory: 7432kb
input:
83568
output:
27855 13929 55711 69639 13930 55712 69640 13931 55713 69641 13932 55714 69642 13933 55715 69643 13934 55716 69644 13935 55717 69645 13936 55718 69646 13937 55719 69647 13938 55720 69648 13939 55721 69649 13940 55722 69650 13941 55723 69651 13942 55724 69652 13943 55725 69653 13944 55726 69654 13945 ...
result:
ok OK 27855 triangles!
Test #23:
score: 0
Accepted
time: 7ms
memory: 5508kb
input:
41476
output:
13825 6914 27651 34564 6915 27652 34565 6916 27653 34566 6917 27654 34567 6918 27655 34568 6919 27656 34569 6920 27657 34570 6921 27658 34571 6922 27659 34572 6923 27660 34573 6924 27661 34574 6925 27662 34575 6926 27663 34576 6927 27664 34577 6928 27665 34578 6929 27666 34579 6930 27667 34580 6931 ...
result:
ok OK 13825 triangles!
Test #24:
score: 0
Accepted
time: 11ms
memory: 6456kb
input:
61028
output:
20342 10173 40686 50857 10174 40687 50858 10175 40688 50859 10176 40689 50860 10177 40690 50861 10178 40691 50862 10179 40692 50863 10180 40693 50864 10181 40694 50865 10182 40695 50866 10183 40696 50867 10184 40697 50868 10185 40698 50869 10186 40699 50870 10187 40700 50871 10188 40701 50872 10189 ...
result:
ok OK 20342 triangles!
Test #25:
score: 0
Accepted
time: 3ms
memory: 5128kb
input:
34231
output:
11410 5707 22822 28527 5708 22823 28528 5709 22824 28529 5710 22825 28530 5711 22826 28531 5712 22827 28532 5713 22828 28533 5714 22829 28534 5715 22830 28535 5716 22831 28536 5717 22832 28537 5718 22833 28538 5719 22834 28539 5720 22835 28540 5721 22836 28541 5722 22837 28542 5723 22838 28543 5724 ...
result:
ok OK 11410 triangles!
Test #26:
score: 0
Accepted
time: 2ms
memory: 4060kb
input:
10000
output:
3333 1668 6667 8334 1669 6668 8335 1670 6669 8336 1671 6670 8337 1672 6671 8338 1673 6672 8339 1674 6673 8340 1675 6674 8341 1676 6675 8342 1677 6676 8343 1678 6677 8344 1679 6678 8345 1680 6679 8346 1681 6680 8347 1682 6681 8348 1683 6682 8349 1684 6683 8350 1685 6684 8351 1686 6685 8352 1687 6686 ...
result:
ok OK 3333 triangles!
Test #27:
score: 0
Accepted
time: 2ms
memory: 4000kb
input:
8370
output:
2789 1396 5579 6974 1397 5580 6975 1398 5581 6976 1399 5582 6977 1400 5583 6978 1401 5584 6979 1402 5585 6980 1403 5586 6981 1404 5587 6982 1405 5588 6983 1406 5589 6984 1407 5590 6985 1408 5591 6986 1409 5592 6987 1410 5593 6988 1411 5594 6989 1412 5595 6990 1413 5596 6991 1414 5597 6992 1415 5598 ...
result:
ok OK 2789 triangles!
Test #28:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
5858
output:
1952 978 3906 4882 979 3907 4883 980 3908 4884 981 3909 4885 982 3910 4886 983 3911 4887 984 3912 4888 985 3913 4889 986 3914 4890 987 3915 4891 988 3916 4892 989 3917 4893 990 3918 4894 991 3919 4895 992 3920 4896 993 3921 4897 994 3922 4898 995 3923 4899 996 3924 4900 997 3925 4901 998 3926 4902 9...
result:
ok OK 1952 triangles!
Test #29:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
688
output:
229 116 459 574 117 460 575 118 461 576 119 462 577 120 463 578 121 464 579 122 465 580 123 466 581 124 467 582 125 468 583 126 469 584 127 470 585 128 471 586 129 472 587 130 473 588 131 474 589 132 475 590 133 476 591 134 477 592 135 478 593 136 479 594 137 480 595 138 481 596 139 482 597 140 483 ...
result:
ok OK 229 triangles!
Test #30:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
6480
output:
2159 1081 4319 5399 1082 4320 5400 1083 4321 5401 1084 4322 5402 1085 4323 5403 1086 4324 5404 1087 4325 5405 1088 4326 5406 1089 4327 5407 1090 4328 5408 1091 4329 5409 1092 4330 5410 1093 4331 5411 1094 4332 5412 1095 4333 5413 1096 4334 5414 1097 4335 5415 1098 4336 5416 1099 4337 5417 1100 4338 ...
result:
ok OK 2159 triangles!
Test #31:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1000
output:
333 168 667 834 169 668 835 170 669 836 171 670 837 172 671 838 173 672 839 174 673 840 175 674 841 176 675 842 177 676 843 178 677 844 179 678 845 180 679 846 181 680 847 182 681 848 183 682 849 184 683 850 185 684 851 186 685 852 187 686 853 188 687 854 189 688 855 190 689 856 191 690 857 192 691 ...
result:
ok OK 333 triangles!
Test #32:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
491
output:
163 83 327 409 84 328 410 85 329 411 86 330 412 87 331 413 88 332 414 89 333 415 90 334 416 91 335 417 92 336 418 93 337 419 94 338 420 95 339 421 96 340 422 97 341 423 98 342 424 99 343 425 100 344 426 101 345 427 102 346 428 103 347 429 104 348 430 105 349 431 106 350 432 107 351 433 108 352 434 1...
result:
ok OK 163 triangles!
Test #33:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
667
output:
222 113 446 557 114 447 558 115 448 559 116 449 560 117 450 561 118 451 562 119 452 563 120 453 564 121 454 565 122 455 566 123 456 567 124 457 568 125 458 569 126 459 570 127 460 571 128 461 572 129 462 573 130 463 574 131 464 575 132 465 576 133 466 577 134 467 578 135 468 579 136 469 580 137 470 ...
result:
ok OK 222 triangles!
Test #34:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
63
output:
20 12 42 52 13 43 53 14 44 54 15 45 55 16 46 56 17 47 57 18 48 58 19 49 59 20 50 60 21 51 61 7 32 37 8 33 38 9 34 39 10 35 40 11 36 41 4 26 29 5 27 30 6 28 31 3 24 25 2 22 23
result:
ok OK 20 triangles!
Test #35:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
682
output:
227 115 455 569 116 456 570 117 457 571 118 458 572 119 459 573 120 460 574 121 461 575 122 462 576 123 463 577 124 464 578 125 465 579 126 466 580 127 467 581 128 468 582 129 469 583 130 470 584 131 471 585 132 472 586 133 473 587 134 474 588 135 475 589 136 476 590 137 477 591 138 478 592 139 479 ...
result:
ok OK 227 triangles!
Test #36:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100
output:
33 18 67 84 19 68 85 20 69 86 21 70 87 22 71 88 23 72 89 24 73 90 25 74 91 26 75 92 27 76 93 28 77 94 29 78 95 30 79 96 31 80 97 32 81 98 33 82 99 34 83 100 10 51 59 11 52 60 12 53 61 13 54 62 14 55 63 15 56 64 16 57 65 17 58 66 6 43 47 7 44 48 8 45 49 9 46 50 4 39 41 5 40 42 3 37 38 2 35 36
result:
ok OK 33 triangles!
Test #37:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
38
output:
12 8 26 32 9 27 33 10 28 34 11 29 35 12 30 36 13 31 37 5 20 23 6 21 24 7 22 25 3 16 18 4 17 19 2 14 15
result:
ok OK 12 triangles!
Test #38:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
167
output:
55 29 111 139 30 112 140 31 113 141 32 114 142 33 115 143 34 116 144 35 117 145 36 118 146 37 119 147 38 120 148 39 121 149 40 122 150 41 123 151 42 124 152 43 125 153 44 126 154 45 127 155 46 128 156 47 129 157 48 130 158 49 131 159 50 132 160 51 133 161 52 134 162 53 135 163 54 136 164 55 137 165 ...
result:
ok OK 55 triangles!
Test #39:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
34
output:
11 7 23 29 8 24 30 9 25 31 10 26 32 11 27 33 12 28 34 4 17 20 5 18 21 6 19 22 3 15 16 2 13 14
result:
ok OK 11 triangles!