QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227156#7526. Credit CardsPiashy#AC ✓48ms24688kbC++201.7kb2023-10-26 23:51:052023-10-26 23:51:06

Judging History

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

  • [2023-10-26 23:51:06]
  • 评测
  • 测评结果:AC
  • 用时:48ms
  • 内存:24688kb
  • [2023-10-26 23:51:05]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int) a.size()

const int inf = (int)1e9;
const ll linf = (ll)2e18;

const ll mod = (ll)1e9 + 7ll;

void solve() {
	int n; cin >> n;

	n = (n - 1) / 3;

	cout << n << "\n";
	vector<vector<int>> ans;

	while (n >= 4) {
		int t = (3 * n + 6) / 5;

		for (int a = 3 * n - 3 * t + 2; a <= 3 * n - 2 * t + 1; ++a) {
			ans.push_back({a, a + t, a + 2 * t});
		}

		n -= t;
	}

	if (n == 3) {
		ans.push_back({ 2, 9, 10 });
		ans.push_back({ 3, 5, 7 });
		ans.push_back({ 4, 6, 8 });
	}
	else if (n == 2) {
		ans.push_back({ 2, 4, 5 });
		ans.push_back({ 3, 6, 7 });
	}
	else if (n == 1) {
		ans.push_back({2, 3, 4});
	}

	for (int i = 0; i < sz(ans); ++i) {
		cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << "\n";
	}
}
	

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen("test.in", "r", stdin);
	//freopen("test.in", "w", stdout);
	//cout << fixed << setprecision(7);

	//clock_t start = clock();

	int tet = 1;
	//cin >> tet;
	while (tet--) {
		solve();
	}

	//clock_t end = clock();
	//ld seconds = (ld)(end - start) / CLOCKS_PER_SEC;
	//cout << seconds << "\n";
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3444kb

input:

3

output:

0

result:

ok OK 0 triangles!

Test #2:

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

input:

4

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #3:

score: 0
Accepted
time: 1ms
memory: 3412kb

input:

9

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #4:

score: 0
Accepted
time: 48ms
memory: 23960kb

input:

1000000

output:

333333
399998 599999 800000
399999 600000 800001
400000 600001 800002
400001 600002 800003
400002 600003 800004
400003 600004 800005
400004 600005 800006
400005 600006 800007
400006 600007 800008
400007 600008 800009
400008 600009 800010
400009 600010 800011
400010 600011 800012
400011 600012 800013...

result:

ok OK 333333 triangles!

Test #5:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

1

output:

0

result:

ok OK 0 triangles!

Test #6:

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

input:

2

output:

0

result:

ok OK 0 triangles!

Test #7:

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

input:

5

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #8:

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

input:

6

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #9:

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

input:

7

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #10:

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

input:

8

output:

2
2 4 5
3 6 7

result:

ok OK 2 triangles!

Test #11:

score: 0
Accepted
time: 1ms
memory: 3416kb

input:

10

output:

3
2 9 10
3 5 7
4 6 8

result:

ok OK 3 triangles!

Test #12:

score: 0
Accepted
time: 25ms
memory: 15036kb

input:

621316

output:

207105
248525 372789 497053
248526 372790 497054
248527 372791 497055
248528 372792 497056
248529 372793 497057
248530 372794 497058
248531 372795 497059
248532 372796 497060
248533 372797 497061
248534 372798 497062
248535 372799 497063
248536 372800 497064
248537 372801 497065
248538 372802 497066...

result:

ok OK 207105 triangles!

Test #13:

score: 0
Accepted
time: 38ms
memory: 15956kb

input:

713171

output:

237723
285266 427901 570536
285267 427902 570537
285268 427903 570538
285269 427904 570539
285270 427905 570540
285271 427906 570541
285272 427907 570542
285273 427908 570543
285274 427909 570544
285275 427910 570545
285276 427911 570546
285277 427912 570547
285278 427913 570548
285279 427914 570549...

result:

ok OK 237723 triangles!

Test #14:

score: 0
Accepted
time: 34ms
memory: 24284kb

input:

825609

output:

275202
330242 495364 660486
330243 495365 660487
330244 495366 660488
330245 495367 660489
330246 495368 660490
330247 495369 660491
330248 495370 660492
330249 495371 660493
330250 495372 660494
330251 495373 660495
330252 495374 660496
330253 495375 660497
330254 495376 660498
330255 495377 660499...

result:

ok OK 275202 triangles!

Test #15:

score: 0
Accepted
time: 31ms
memory: 17336kb

input:

782282

output:

260760
312911 469368 625825
312912 469369 625826
312913 469370 625827
312914 469371 625828
312915 469372 625829
312916 469373 625830
312917 469374 625831
312918 469375 625832
312919 469376 625833
312920 469377 625834
312921 469378 625835
312922 469379 625836
312923 469380 625837
312924 469381 625838...

result:

ok OK 260760 triangles!

Test #16:

score: 0
Accepted
time: 4ms
memory: 5816kb

input:

148128

output:

49375
59249 88875 118501
59250 88876 118502
59251 88877 118503
59252 88878 118504
59253 88879 118505
59254 88880 118506
59255 88881 118507
59256 88882 118508
59257 88883 118509
59258 88884 118510
59259 88885 118511
59260 88886 118512
59261 88887 118513
59262 88888 118514
59263 88889 118515
59264 888...

result:

ok OK 49375 triangles!

Test #17:

score: 0
Accepted
time: 28ms
memory: 15544kb

input:

681282

output:

227093
272510 408767 545024
272511 408768 545025
272512 408769 545026
272513 408770 545027
272514 408771 545028
272515 408772 545029
272516 408773 545030
272517 408774 545031
272518 408775 545032
272519 408776 545033
272520 408777 545034
272521 408778 545035
272522 408779 545036
272523 408780 545037...

result:

ok OK 227093 triangles!

Test #18:

score: 0
Accepted
time: 41ms
memory: 24688kb

input:

798547

output:

266182
319418 479128 638838
319419 479129 638839
319420 479130 638840
319421 479131 638841
319422 479132 638842
319423 479133 638843
319424 479134 638844
319425 479135 638845
319426 479136 638846
319427 479137 638847
319428 479138 638848
319429 479139 638849
319430 479140 638850
319431 479141 638851...

result:

ok OK 266182 triangles!

Test #19:

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

input:

349290

output:

116429
139715 209573 279431
139716 209574 279432
139717 209575 279433
139718 209576 279434
139719 209577 279435
139720 209578 279436
139721 209579 279437
139722 209580 279438
139723 209581 279439
139724 209582 279440
139725 209583 279441
139726 209584 279442
139727 209585 279443
139728 209586 279444...

result:

ok OK 116429 triangles!

Test #20:

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

input:

317275

output:

105758
126908 190364 253820
126909 190365 253821
126910 190366 253822
126911 190367 253823
126912 190368 253824
126913 190369 253825
126914 190370 253826
126915 190371 253827
126916 190372 253828
126917 190373 253829
126918 190374 253830
126919 190375 253831
126920 190376 253832
126921 190377 253833...

result:

ok OK 105758 triangles!

Test #21:

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

input:

100000

output:

33333
39998 59999 80000
39999 60000 80001
40000 60001 80002
40001 60002 80003
40002 60003 80004
40003 60004 80005
40004 60005 80006
40005 60006 80007
40006 60007 80008
40007 60008 80009
40008 60009 80010
40009 60010 80011
40010 60011 80012
40011 60012 80013
40012 60013 80014
40013 60014 80015
40014 ...

result:

ok OK 33333 triangles!

Test #22:

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

input:

83568

output:

27855
33425 50139 66853
33426 50140 66854
33427 50141 66855
33428 50142 66856
33429 50143 66857
33430 50144 66858
33431 50145 66859
33432 50146 66860
33433 50147 66861
33434 50148 66862
33435 50149 66863
33436 50150 66864
33437 50151 66865
33438 50152 66866
33439 50153 66867
33440 50154 66868
33441 ...

result:

ok OK 27855 triangles!

Test #23:

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

input:

41476

output:

13825
16589 24885 33181
16590 24886 33182
16591 24887 33183
16592 24888 33184
16593 24889 33185
16594 24890 33186
16595 24891 33187
16596 24892 33188
16597 24893 33189
16598 24894 33190
16599 24895 33191
16600 24896 33192
16601 24897 33193
16602 24898 33194
16603 24899 33195
16604 24900 33196
16605 ...

result:

ok OK 13825 triangles!

Test #24:

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

input:

61028

output:

20342
24410 36616 48822
24411 36617 48823
24412 36618 48824
24413 36619 48825
24414 36620 48826
24415 36621 48827
24416 36622 48828
24417 36623 48829
24418 36624 48830
24419 36625 48831
24420 36626 48832
24421 36627 48833
24422 36628 48834
24423 36629 48835
24424 36630 48836
24425 36631 48837
24426 ...

result:

ok OK 20342 triangles!

Test #25:

score: 0
Accepted
time: 3ms
memory: 3828kb

input:

34231

output:

11410
13691 20538 27385
13692 20539 27386
13693 20540 27387
13694 20541 27388
13695 20542 27389
13696 20543 27390
13697 20544 27391
13698 20545 27392
13699 20546 27393
13700 20547 27394
13701 20548 27395
13702 20549 27396
13703 20550 27397
13704 20551 27398
13705 20552 27399
13706 20553 27400
13707 ...

result:

ok OK 11410 triangles!

Test #26:

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

input:

10000

output:

3333
3998 5999 8000
3999 6000 8001
4000 6001 8002
4001 6002 8003
4002 6003 8004
4003 6004 8005
4004 6005 8006
4005 6006 8007
4006 6007 8008
4007 6008 8009
4008 6009 8010
4009 6010 8011
4010 6011 8012
4011 6012 8013
4012 6013 8014
4013 6014 8015
4014 6015 8016
4015 6016 8017
4016 6017 8018
4017 6018 ...

result:

ok OK 3333 triangles!

Test #27:

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

input:

8370

output:

2789
3347 5021 6695
3348 5022 6696
3349 5023 6697
3350 5024 6698
3351 5025 6699
3352 5026 6700
3353 5027 6701
3354 5028 6702
3355 5029 6703
3356 5030 6704
3357 5031 6705
3358 5032 6706
3359 5033 6707
3360 5034 6708
3361 5035 6709
3362 5036 6710
3363 5037 6711
3364 5038 6712
3365 5039 6713
3366 5040 ...

result:

ok OK 2789 triangles!

Test #28:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

5858

output:

1952
2342 3514 4686
2343 3515 4687
2344 3516 4688
2345 3517 4689
2346 3518 4690
2347 3519 4691
2348 3520 4692
2349 3521 4693
2350 3522 4694
2351 3523 4695
2352 3524 4696
2353 3525 4697
2354 3526 4698
2355 3527 4699
2356 3528 4700
2357 3529 4701
2358 3530 4702
2359 3531 4703
2360 3532 4704
2361 3533 ...

result:

ok OK 1952 triangles!

Test #29:

score: 0
Accepted
time: 1ms
memory: 3420kb

input:

688

output:

229
275 413 551
276 414 552
277 415 553
278 416 554
279 417 555
280 418 556
281 419 557
282 420 558
283 421 559
284 422 560
285 423 561
286 424 562
287 425 563
288 426 564
289 427 565
290 428 566
291 429 567
292 430 568
293 431 569
294 432 570
295 433 571
296 434 572
297 435 573
298 436 574
299 437 ...

result:

ok OK 229 triangles!

Test #30:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

6480

output:

2159
2591 3887 5183
2592 3888 5184
2593 3889 5185
2594 3890 5186
2595 3891 5187
2596 3892 5188
2597 3893 5189
2598 3894 5190
2599 3895 5191
2600 3896 5192
2601 3897 5193
2602 3898 5194
2603 3899 5195
2604 3900 5196
2605 3901 5197
2606 3902 5198
2607 3903 5199
2608 3904 5200
2609 3905 5201
2610 3906 ...

result:

ok OK 2159 triangles!

Test #31:

score: 0
Accepted
time: 1ms
memory: 3436kb

input:

1000

output:

333
398 599 800
399 600 801
400 601 802
401 602 803
402 603 804
403 604 805
404 605 806
405 606 807
406 607 808
407 608 809
408 609 810
409 610 811
410 611 812
411 612 813
412 613 814
413 614 815
414 615 816
415 616 817
416 617 818
417 618 819
418 619 820
419 620 821
420 621 822
421 622 823
422 623 ...

result:

ok OK 333 triangles!

Test #32:

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

input:

491

output:

163
194 293 392
195 294 393
196 295 394
197 296 395
198 297 396
199 298 397
200 299 398
201 300 399
202 301 400
203 302 401
204 303 402
205 304 403
206 305 404
207 306 405
208 307 406
209 308 407
210 309 408
211 310 409
212 311 410
213 312 411
214 313 412
215 314 413
216 315 414
217 316 415
218 317 ...

result:

ok OK 163 triangles!

Test #33:

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

input:

667

output:

222
266 400 534
267 401 535
268 402 536
269 403 537
270 404 538
271 405 539
272 406 540
273 407 541
274 408 542
275 409 543
276 410 544
277 411 545
278 412 546
279 413 547
280 414 548
281 415 549
282 416 550
283 417 551
284 418 552
285 419 553
286 420 554
287 421 555
288 422 556
289 423 557
290 424 ...

result:

ok OK 222 triangles!

Test #34:

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

input:

63

output:

20
23 36 49
24 37 50
25 38 51
26 39 52
27 40 53
28 41 54
29 42 55
30 43 56
31 44 57
32 45 58
33 46 59
34 47 60
35 48 61
8 13 18
9 14 19
10 15 20
11 16 21
12 17 22
2 4 5
3 6 7

result:

ok OK 20 triangles!

Test #35:

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

input:

682

output:

227
272 409 546
273 410 547
274 411 548
275 412 549
276 413 550
277 414 551
278 415 552
279 416 553
280 417 554
281 418 555
282 419 556
283 420 557
284 421 558
285 422 559
286 423 560
287 424 561
288 425 562
289 426 563
290 427 564
291 428 565
292 429 566
293 430 567
294 431 568
295 432 569
296 433 ...

result:

ok OK 227 triangles!

Test #36:

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

input:

100

output:

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

result:

ok OK 33 triangles!

Test #37:

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

input:

38

output:

12
14 22 30
15 23 31
16 24 32
17 25 33
18 26 34
19 27 35
20 28 36
21 29 37
5 8 11
6 9 12
7 10 13
2 3 4

result:

ok OK 12 triangles!

Test #38:

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

input:

167

output:

55
65 99 133
66 100 134
67 101 135
68 102 136
69 103 137
70 104 138
71 105 139
72 106 140
73 107 141
74 108 142
75 109 143
76 110 144
77 111 145
78 112 146
79 113 147
80 114 148
81 115 149
82 116 150
83 117 151
84 118 152
85 119 153
86 120 154
87 121 155
88 122 156
89 123 157
90 124 158
91 125 159
9...

result:

ok OK 55 triangles!

Test #39:

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

input:

34

output:

11
14 21 28
15 22 29
16 23 30
17 24 31
18 25 32
19 26 33
20 27 34
5 8 11
6 9 12
7 10 13
2 3 4

result:

ok OK 11 triangles!