QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#191323#7526. Credit CardsDays_of_Future_Past#AC ✓34ms11324kbC++141.1kb2023-09-29 21:47:322023-09-29 21:47:33

Judging History

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

  • [2023-09-29 21:47:33]
  • 评测
  • 测评结果:AC
  • 用时:34ms
  • 内存:11324kb
  • [2023-09-29 21:47:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long LL;
const int N = 1000011;
int vst[N];
vector<array<int, 3> > ans;
int main() {
	int n;
	scanf("%d", &n);
	if(n % 3 == 0) {
		n -= 2;
	}
	if(n % 3 == 2) {
		n -= 1;
	}
	if(n == 10) {
		ans.pb({4, 9, 10});
		ans.pb({3, 7, 8});
		ans.pb({2, 5, 6});
	}else {
		int m;
		int st;
		if((n / 3) % 2 == 1) {
			ans.pb({2, n - 1, n});
			m = n / 3 - 1;
			n -= 2;
			st = 3;
		}else {
			m = n / 3;
			st = 2;
		}

		int le[2], ri[2];
		le[0] = n - m * 2 + 1, ri[0] = n - m;
		le[1] = n - m + 1, ri[1] = n;
		for(int i = m - 1; i >= 0; i--) {
			ans.pb({st + i, le[i % 2], ri[i % 2]});
			le[i % 2]++;
			ri[i % 2]--;
		}
	}
	printf("%d\n", (int)ans.size());
	for(auto t : ans) {
		printf("%d %d %d\n", t[0], t[1], t[2]);
		assert(vst[t[0]] == false && vst[t[1]] == false && vst[t[2]] == false);
		vst[t[0]] = vst[t[1]] = vst[t[2]] = true;
		assert(t[0] + t[1] > t[2]);
		assert(t[0] < t[2] && t[1] < t[2]);
		assert((LL)t[0] * t[0] + (LL)t[1] * t[1] < (LL)t[2] * t[2]);
	}
}

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

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3792kb

input:

3

output:

0

result:

ok OK 0 triangles!

Test #2:

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

input:

4

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #3:

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

input:

9

output:

2
3 6 7
2 4 5

result:

ok OK 2 triangles!

Test #4:

score: 0
Accepted
time: 30ms
memory: 11324kb

input:

1000000

output:

333333
2 999999 1000000
333334 666667 999998
333333 333335 666666
333332 666668 999997
333331 333336 666665
333330 666669 999996
333329 333337 666664
333328 666670 999995
333327 333338 666663
333326 666671 999994
333325 333339 666662
333324 666672 999993
333323 333340 666661
333322 666673 999992
333...

result:

ok OK 333333 triangles!

Test #5:

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

input:

1

output:

0

result:

ok OK 0 triangles!

Test #6:

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

input:

2

output:

0

result:

ok OK 0 triangles!

Test #7:

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

input:

5

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #8:

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

input:

6

output:

1
2 3 4

result:

ok OK 1 triangles!

Test #9:

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

input:

7

output:

2
3 6 7
2 4 5

result:

ok OK 2 triangles!

Test #10:

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

input:

8

output:

2
3 6 7
2 4 5

result:

ok OK 2 triangles!

Test #11:

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

input:

10

output:

3
4 9 10
3 7 8
2 5 6

result:

ok OK 3 triangles!

Test #12:

score: 0
Accepted
time: 24ms
memory: 8328kb

input:

621316

output:

207105
2 621315 621316
207106 414211 621314
207105 207107 414210
207104 414212 621313
207103 207108 414209
207102 414213 621312
207101 207109 414208
207100 414214 621311
207099 207110 414207
207098 414215 621310
207097 207111 414206
207096 414216 621309
207095 207112 414205
207094 414217 621308
2070...

result:

ok OK 207105 triangles!

Test #13:

score: 0
Accepted
time: 20ms
memory: 9008kb

input:

713171

output:

237723
2 713169 713170
237724 475447 713168
237723 237725 475446
237722 475448 713167
237721 237726 475445
237720 475449 713166
237719 237727 475444
237718 475450 713165
237717 237728 475443
237716 475451 713164
237715 237729 475442
237714 475452 713163
237713 237730 475441
237712 475453 713162
2377...

result:

ok OK 237723 triangles!

Test #14:

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

input:

825609

output:

275202
275203 550406 825607
275202 275204 550405
275201 550407 825606
275200 275205 550404
275199 550408 825605
275198 275206 550403
275197 550409 825604
275196 275207 550402
275195 550410 825603
275194 275208 550401
275193 550411 825602
275192 275209 550400
275191 550412 825601
275190 275210 550399...

result:

ok OK 275202 triangles!

Test #15:

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

input:

782282

output:

260760
260761 521522 782281
260760 260762 521521
260759 521523 782280
260758 260763 521520
260757 521524 782279
260756 260764 521519
260755 521525 782278
260754 260765 521518
260753 521526 782277
260752 260766 521517
260751 521527 782276
260750 260767 521516
260749 521528 782275
260748 260768 521515...

result:

ok OK 260760 triangles!

Test #16:

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

input:

148128

output:

49375
2 148125 148126
49376 98751 148124
49375 49377 98750
49374 98752 148123
49373 49378 98749
49372 98753 148122
49371 49379 98748
49370 98754 148121
49369 49380 98747
49368 98755 148120
49367 49381 98746
49366 98756 148119
49365 49382 98745
49364 98757 148118
49363 49383 98744
49362 98758 148117
...

result:

ok OK 49375 triangles!

Test #17:

score: 0
Accepted
time: 30ms
memory: 8564kb

input:

681282

output:

227093
2 681279 681280
227094 454187 681278
227093 227095 454186
227092 454188 681277
227091 227096 454185
227090 454189 681276
227089 227097 454184
227088 454190 681275
227087 227098 454183
227086 454191 681274
227085 227099 454182
227084 454192 681273
227083 227100 454181
227082 454193 681272
2270...

result:

ok OK 227093 triangles!

Test #18:

score: 0
Accepted
time: 32ms
memory: 10552kb

input:

798547

output:

266182
266183 532366 798547
266182 266184 532365
266181 532367 798546
266180 266185 532364
266179 532368 798545
266178 266186 532363
266177 532369 798544
266176 266187 532362
266175 532370 798543
266174 266188 532361
266173 532371 798542
266172 266189 532360
266171 532372 798541
266170 266190 532359...

result:

ok OK 266182 triangles!

Test #19:

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

input:

349290

output:

116429
2 349287 349288
116430 232859 349286
116429 116431 232858
116428 232860 349285
116427 116432 232857
116426 232861 349284
116425 116433 232856
116424 232862 349283
116423 116434 232855
116422 232863 349282
116421 116435 232854
116420 232864 349281
116419 116436 232853
116418 232865 349280
1164...

result:

ok OK 116429 triangles!

Test #20:

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

input:

317275

output:

105758
105759 211518 317275
105758 105760 211517
105757 211519 317274
105756 105761 211516
105755 211520 317273
105754 105762 211515
105753 211521 317272
105752 105763 211514
105751 211522 317271
105750 105764 211513
105749 211523 317270
105748 105765 211512
105747 211524 317269
105746 105766 211511...

result:

ok OK 105758 triangles!

Test #21:

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

input:

100000

output:

33333
2 99999 100000
33334 66667 99998
33333 33335 66666
33332 66668 99997
33331 33336 66665
33330 66669 99996
33329 33337 66664
33328 66670 99995
33327 33338 66663
33326 66671 99994
33325 33339 66662
33324 66672 99993
33323 33340 66661
33322 66673 99992
33321 33341 66660
33320 66674 99991
33319 333...

result:

ok OK 33333 triangles!

Test #22:

score: 0
Accepted
time: 2ms
memory: 3980kb

input:

83568

output:

27855
2 83565 83566
27856 55711 83564
27855 27857 55710
27854 55712 83563
27853 27858 55709
27852 55713 83562
27851 27859 55708
27850 55714 83561
27849 27860 55707
27848 55715 83560
27847 27861 55706
27846 55716 83559
27845 27862 55705
27844 55717 83558
27843 27863 55704
27842 55718 83557
27841 2786...

result:

ok OK 27855 triangles!

Test #23:

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

input:

41476

output:

13825
2 41475 41476
13826 27651 41474
13825 13827 27650
13824 27652 41473
13823 13828 27649
13822 27653 41472
13821 13829 27648
13820 27654 41471
13819 13830 27647
13818 27655 41470
13817 13831 27646
13816 27656 41469
13815 13832 27645
13814 27657 41468
13813 13833 27644
13812 27658 41467
13811 1383...

result:

ok OK 13825 triangles!

Test #24:

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

input:

61028

output:

20342
20343 40686 61027
20342 20344 40685
20341 40687 61026
20340 20345 40684
20339 40688 61025
20338 20346 40683
20337 40689 61024
20336 20347 40682
20335 40690 61023
20334 20348 40681
20333 40691 61022
20332 20349 40680
20331 40692 61021
20330 20350 40679
20329 40693 61020
20328 20351 40678
20327 ...

result:

ok OK 20342 triangles!

Test #25:

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

input:

34231

output:

11410
11411 22822 34231
11410 11412 22821
11409 22823 34230
11408 11413 22820
11407 22824 34229
11406 11414 22819
11405 22825 34228
11404 11415 22818
11403 22826 34227
11402 11416 22817
11401 22827 34226
11400 11417 22816
11399 22828 34225
11398 11418 22815
11397 22829 34224
11396 11419 22814
11395 ...

result:

ok OK 11410 triangles!

Test #26:

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

input:

10000

output:

3333
2 9999 10000
3334 6667 9998
3333 3335 6666
3332 6668 9997
3331 3336 6665
3330 6669 9996
3329 3337 6664
3328 6670 9995
3327 3338 6663
3326 6671 9994
3325 3339 6662
3324 6672 9993
3323 3340 6661
3322 6673 9992
3321 3341 6660
3320 6674 9991
3319 3342 6659
3318 6675 9990
3317 3343 6658
3316 6676 99...

result:

ok OK 3333 triangles!

Test #27:

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

input:

8370

output:

2789
2 8367 8368
2790 5579 8366
2789 2791 5578
2788 5580 8365
2787 2792 5577
2786 5581 8364
2785 2793 5576
2784 5582 8363
2783 2794 5575
2782 5583 8362
2781 2795 5574
2780 5584 8361
2779 2796 5573
2778 5585 8360
2777 2797 5572
2776 5586 8359
2775 2798 5571
2774 5587 8358
2773 2799 5570
2772 5588 835...

result:

ok OK 2789 triangles!

Test #28:

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

input:

5858

output:

1952
1953 3906 5857
1952 1954 3905
1951 3907 5856
1950 1955 3904
1949 3908 5855
1948 1956 3903
1947 3909 5854
1946 1957 3902
1945 3910 5853
1944 1958 3901
1943 3911 5852
1942 1959 3900
1941 3912 5851
1940 1960 3899
1939 3913 5850
1938 1961 3898
1937 3914 5849
1936 1962 3897
1935 3915 5848
1934 1963 ...

result:

ok OK 1952 triangles!

Test #29:

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

input:

688

output:

229
2 687 688
230 459 686
229 231 458
228 460 685
227 232 457
226 461 684
225 233 456
224 462 683
223 234 455
222 463 682
221 235 454
220 464 681
219 236 453
218 465 680
217 237 452
216 466 679
215 238 451
214 467 678
213 239 450
212 468 677
211 240 449
210 469 676
209 241 448
208 470 675
207 242 44...

result:

ok OK 229 triangles!

Test #30:

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

input:

6480

output:

2159
2 6477 6478
2160 4319 6476
2159 2161 4318
2158 4320 6475
2157 2162 4317
2156 4321 6474
2155 2163 4316
2154 4322 6473
2153 2164 4315
2152 4323 6472
2151 2165 4314
2150 4324 6471
2149 2166 4313
2148 4325 6470
2147 2167 4312
2146 4326 6469
2145 2168 4311
2144 4327 6468
2143 2169 4310
2142 4328 646...

result:

ok OK 2159 triangles!

Test #31:

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

input:

1000

output:

333
2 999 1000
334 667 998
333 335 666
332 668 997
331 336 665
330 669 996
329 337 664
328 670 995
327 338 663
326 671 994
325 339 662
324 672 993
323 340 661
322 673 992
321 341 660
320 674 991
319 342 659
318 675 990
317 343 658
316 676 989
315 344 657
314 677 988
313 345 656
312 678 987
311 346 6...

result:

ok OK 333 triangles!

Test #32:

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

input:

491

output:

163
2 489 490
164 327 488
163 165 326
162 328 487
161 166 325
160 329 486
159 167 324
158 330 485
157 168 323
156 331 484
155 169 322
154 332 483
153 170 321
152 333 482
151 171 320
150 334 481
149 172 319
148 335 480
147 173 318
146 336 479
145 174 317
144 337 478
143 175 316
142 338 477
141 176 31...

result:

ok OK 163 triangles!

Test #33:

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

input:

667

output:

222
223 446 667
222 224 445
221 447 666
220 225 444
219 448 665
218 226 443
217 449 664
216 227 442
215 450 663
214 228 441
213 451 662
212 229 440
211 452 661
210 230 439
209 453 660
208 231 438
207 454 659
206 232 437
205 455 658
204 233 436
203 456 657
202 234 435
201 457 656
200 235 434
199 458 ...

result:

ok OK 222 triangles!

Test #34:

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

input:

63

output:

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

result:

ok OK 20 triangles!

Test #35:

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

input:

682

output:

227
2 681 682
228 455 680
227 229 454
226 456 679
225 230 453
224 457 678
223 231 452
222 458 677
221 232 451
220 459 676
219 233 450
218 460 675
217 234 449
216 461 674
215 235 448
214 462 673
213 236 447
212 463 672
211 237 446
210 464 671
209 238 445
208 465 670
207 239 444
206 466 669
205 240 44...

result:

ok OK 227 triangles!

Test #36:

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

input:

100

output:

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

result:

ok OK 33 triangles!

Test #37:

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

input:

38

output:

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

result:

ok OK 12 triangles!

Test #38:

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

input:

167

output:

55
2 165 166
56 111 164
55 57 110
54 112 163
53 58 109
52 113 162
51 59 108
50 114 161
49 60 107
48 115 160
47 61 106
46 116 159
45 62 105
44 117 158
43 63 104
42 118 157
41 64 103
40 119 156
39 65 102
38 120 155
37 66 101
36 121 154
35 67 100
34 122 153
33 68 99
32 123 152
31 69 98
30 124 151
29 70...

result:

ok OK 55 triangles!

Test #39:

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

input:

34

output:

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

result:

ok OK 11 triangles!