QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65510#5091. 大冬天题feecle6418100 ✓955ms182048kbC++141.1kb2022-12-01 15:50:462022-12-01 15:50:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-01 15:50:49]
  • 评测
  • 测评结果:100
  • 用时:955ms
  • 内存:182048kb
  • [2022-12-01 15:50:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000000,mod=1e9+7;
typedef pair<int,int> pr;
int m,a[N+5],b[N+5],vst[2*N+5],t[2*N+5],good[N+5],cnt=0;
vector<int> p[4*N+5];
void Mark(int x,int y){
	cnt++;
	for(auto u:p[x])t[u]=y;
}
bool Has(int x){
	cnt++;
	for(auto u:p[x])if(t[u])return 1;
	return 0;
}
int main(){
	for(int i=2;i<=2*N;i++){
		if(vst[i])continue;
		for(ll j=1ll*i*i;j<=2*N;j+=i)vst[j]=1;
	}
	string vn;
	cin>>vn>>m;
	cout<<m<<'\n';
	for(int i=1;i<=m;i++)a[i]=2*i-1+2*m,b[i]=2*i-1;
	for(int i=3;i<=2*m-1;i+=2){
		if(vst[i]||(m>100000&&i>m))continue;
		int nmodi=0;
		for(char ch:vn)nmodi=(nmodi*10+ch-'0')%i; 
		int L=i-(nmodi-2*m%i+i)%i;
		for(int j=L;j<4*m;j+=i)if(j%2==1)p[j].push_back(i);
	}
	mt19937_64 rng(233);
	shuffle(b+1,b+m+1,rng);
	while(1){
		bool ok=1;
		for(int i=1;i<=m;i++){
			if(good[i])continue;
			int k=i%m+1;
			Mark(a[i],1);
			while(Has(b[i]))swap(b[i],b[k]),good[k]=0,ok=0,k=k%m+1;
			Mark(a[i],0),good[i]=1;
		}
		if(ok)break;
	}
	for(int j=1;j<=m;j++){
		int val=b[j];
		cout<<(2*m-val+1)/2<<'\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 26ms
memory: 110856kb

input:

527901620 3

output:

3
2
3
1

result:

ok Accepted.

Test #2:

score: 5
Accepted
time: 27ms
memory: 108708kb

input:

423744200 1

output:

1
1

result:

ok Accepted.

Test #3:

score: 5
Accepted
time: 19ms
memory: 111332kb

input:

870873520 8

output:

8
8
2
5
1
7
3
4
6

result:

ok Accepted.

Test #4:

score: 5
Accepted
time: 34ms
memory: 110792kb

input:

796450080 10

output:

10
1
4
9
3
6
5
7
10
8
2

result:

ok Accepted.

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 5
Accepted
time: 23ms
memory: 109872kb

input:

691352244 2

output:

2
2
1

result:

ok Accepted.

Test #6:

score: 5
Accepted
time: 22ms
memory: 111644kb

input:

537735946 4

output:

4
4
1
2
3

result:

ok Accepted.

Test #7:

score: 5
Accepted
time: 23ms
memory: 109080kb

input:

964421466 6

output:

6
2
6
4
5
3
1

result:

ok Accepted.

Test #8:

score: 5
Accepted
time: 33ms
memory: 110580kb

input:

804640404 8

output:

8
8
1
2
7
3
4
5
6

result:

ok Accepted.

Subtask #3:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 15
Accepted
time: 26ms
memory: 110740kb

input:

815904616 163

output:

163
71
53
78
151
107
101
29
51
12
27
2
32
58
49
150
46
52
93
4
70
95
97
155
3
69
76
60
8
37
23
74
6
63
118
5
152
154
156
129
82
104
41
121
103
140
148
139
141
85
94
17
9
102
99
38
81
35
34
64
143
88
55
33
136
28
11
145
7
123
67
112
117
21
39
14
127
19
48
142
132
147
161
22
108
50
146
135
91
138
153
...

result:

ok Accepted.

Test #10:

score: 15
Accepted
time: 16ms
memory: 111784kb

input:

261467732 174

output:

174
125
80
17
157
148
87
58
108
24
14
15
81
119
164
93
16
82
44
124
170
167
158
66
55
71
145
72
20
173
86
97
18
174
152
150
153
128
171
94
19
116
73
61
147
3
131
25
99
121
35
135
5
6
149
50
102
46
23
136
139
7
165
40
43
154
133
118
21
110
137
168
127
166
159
75
2
26
60
83
47
34
107
39
62
67
140
77
1...

result:

ok Accepted.

Test #11:

score: 15
Accepted
time: 22ms
memory: 111332kb

input:

170135212 52

output:

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

result:

ok Accepted.

Test #12:

score: 15
Accepted
time: 19ms
memory: 111816kb

input:

914972990 139

output:

139
47
29
54
127
77
83
5
27
38
34
3
18
25
28
22
55
46
126
8
69
73
71
131
30
52
45
36
49
96
13
50
135
39
94
130
109
128
105
58
80
132
97
17
79
124
115
61
117
70
116
37
35
75
78
10
14
57
40
64
11
119
31
112
4
9
121
95
91
43
88
99
93
65
15
103
98
20
24
118
137
108
7
84
123
26
122
67
16
114
111
107
129
...

result:

ok Accepted.

Subtask #4:

score: 10
Accepted

Dependency #3:

100%
Accepted

Test #13:

score: 10
Accepted
time: 27ms
memory: 111884kb

input:

303514006 1401

output:

1401
646
1099
512
1233
1089
116
1345
1159
1058
1265
837
543
1179
976
1227
524
186
404
986
924
1331
1335
261
1241
978
1184
56
587
1275
704
307
143
1301
538
1198
1392
1065
155
620
613
191
1206
1279
896
1124
78
1323
1379
1103
403
131
694
1340
1218
582
285
207
654
890
102
460
1293
308
765
667
968
953
36...

result:

ok Accepted.

Test #14:

score: 10
Accepted
time: 29ms
memory: 110284kb

input:

651391026 1584

output:

1584
1355
696
305
1567
1558
371
495
300
1242
677
1491
1529
1389
931
1160
211
139
588
1125
655
1203
613
757
1465
293
1071
1583
240
888
1247
630
783
1289
587
945
722
1581
553
26
555
1050
1390
1471
1080
845
262
505
1435
581
859
1397
345
1249
713
1339
766
1395
172
1074
644
286
492
261
333
130
141
617
13...

result:

ok Accepted.

Test #15:

score: 10
Accepted
time: 28ms
memory: 110940kb

input:

196126306 1766

output:

1766
1537
487
878
1749
1740
677
553
482
1424
1673
859
1113
1711
1571
393
1342
321
770
1307
1385
837
795
939
1647
1253
475
422
1429
1765
812
1070
1471
965
769
904
1127
1763
735
737
1232
208
1572
1653
1262
444
1027
687
1617
763
52
1041
527
895
1521
948
1431
1577
354
1256
468
826
674
443
323
515
180
79...

result:

ok Accepted.

Test #16:

score: 10
Accepted
time: 29ms
memory: 111432kb

input:

904263684 1948

output:

1948
1719
669
1060
1931
735
1922
859
664
1606
1855
1041
1893
1753
1524
47
503
952
575
1489
1567
62
977
127
1829
1435
657
604
1611
1947
109
1252
1653
951
1086
1147
1309
1945
919
917
1414
1444
390
1754
1209
1835
626
945
869
1799
234
1223
709
1077
1613
1130
1759
1703
536
1438
650
1008
856
625
697
505
9...

result:

ok Accepted.

Subtask #5:

score: 25
Accepted

Test #17:

score: 25
Accepted
time: 656ms
memory: 158236kb

input:

1434450 717225

output:

717225
408289
561156
612072
311544
145549
47016
39034
208794
137169
396937
647467
70607
79471
366457
387763
319021
237445
199440
632792
506745
116891
635025
54000
40364
588083
292488
154388
461717
478486
578461
668358
481999
280472
208212
521967
282727
367564
555831
195652
479672
480852
380863
25202...

result:

ok Accepted.

Test #18:

score: 25
Accepted
time: 747ms
memory: 166296kb

input:

1666706 833353

output:

833353
524417
70298
728200
261677
107490
155162
163144
324922
253297
513065
763595
186735
195599
482585
435149
503891
353573
315568
622873
748920
233019
7228
156492
99997
31580
704211
577845
408616
594614
694589
784486
598127
396600
324340
638095
398855
483692
671959
311780
596980
595800
496991
3681...

result:

ok Accepted.

Test #19:

score: 25
Accepted
time: 749ms
memory: 169532kb

input:

1768146 884073

output:

884073
575137
121018
778920
158210
312397
205882
213864
375642
304017
237455
563785
814315
246319
533305
485869
554611
404293
366288
799640
673593
283739
57948
150717
754931
207212
82300
628565
459336
645334
745309
835206
648847
447320
375060
688815
449575
534412
722679
362500
647700
17671
547711
41...

result:

ok Accepted.

Test #20:

score: 25
Accepted
time: 704ms
memory: 155996kb

input:

1333926 666963

output:

666963
273461
510894
561810
261282
95287
337367
264754
158532
86907
346675
597205
20345
29209
316195
268759
337501
187183
149178
582530
456483
66629
584763
216066
3738
411455
242226
537821
104126
428224
528199
618096
431737
230210
157950
471705
232465
317302
505569
145390
429410
430590
330601
201762...

result:

ok Accepted.

Subtask #6:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #21:

score: 10
Accepted
time: 36ms
memory: 113128kb

input:

121768078 34399

output:

34399
25383
27151
27314
2016
6307
6414
13567
33114
29949
19135
28791
29124
28245
9344
29282
33522
3297
5597
268
22017
1665
11830
1244
18215
745
22467
12612
13980
24294
17975
25086
26917
24591
33536
34390
7107
9751
22510
32840
17540
16284
23496
9607
8905
8243
13966
775
17331
29635
31268
10280
18348
3...

result:

ok Accepted.

Test #22:

score: 10
Accepted
time: 38ms
memory: 113224kb

input:

567903556 38581

output:

38581
32044
1691
31496
31333
10489
10596
17749
37296
435
23317
32973
33306
32427
33464
37704
13526
7479
9779
4450
26199
5847
16012
5426
26649
16794
22397
18162
4927
2594
22157
29268
544
28773
11289
37718
37022
38572
13933
21722
26692
4113
3263
13789
27678
21513
13087
18148
14462
4957
33817
35450
225...

result:

ok Accepted.

Test #23:

score: 10
Accepted
time: 31ms
memory: 113984kb

input:

414440938 42763

output:

42763
19042
22765
14778
35515
14671
10380
1081
41478
37155
2282
4617
36609
37488
37646
17708
41886
11661
13961
548
8632
10029
20194
9608
30831
20976
26579
22344
9109
6776
33450
4726
26339
32955
41900
15471
41204
42754
18115
25904
30874
8295
1302
31860
17269
18644
22330
1003
25695
9139
37999
39632
26...

result:

ok Accepted.

Test #24:

score: 10
Accepted
time: 42ms
memory: 114340kb

input:

310652458 46946

output:

46946
20986
46058
17247
3538
6237
18962
35088
36903
29055
6466
43406
41672
36481
45573
19007
44625
21892
12816
13371
4732
24378
25849
9287
25160
39872
23097
11807
26528
10960
21747
30253
8910
41720
35919
32324
37173
35513
14777
5486
1453
30088
28832
36044
37161
13775
26429
44880
46797
18459
3192
223...

result:

ok Accepted.

Subtask #7:

score: 15
Accepted

Dependency #6:

100%
Accepted

Test #25:

score: 15
Accepted
time: 899ms
memory: 180200kb

input:

385664412 991454

output:

991454
746165
228400
7426
265592
631663
7168
321246
305955
180359
714485
315037
521543
662117
718228
395819
94794
173457
794621
193403
165330
810422
638327
328230
314594
189682
471421
752716
304679
58284
937698
831405
302725
554702
482442
521631
659439
290035
641794
469882
69959
755082
751783
526254...

result:

ok Accepted.

Test #26:

score: 15
Accepted
time: 233ms
memory: 129464kb

input:

795580394 295636

output:

295636
139568
292110
190484
237964
99423
45758
204223
44889
238470
18667
17577
104629
240712
285171
22410
294263
98803
261506
211204
114604
24917
121153
145735
206241
131729
129516
171280
241880
208713
56898
135587
72705
62225
205039
107574
14429
72445
52363
197839
59264
51261
55965
284734
25527
748...

result:

ok Accepted.

Test #27:

score: 15
Accepted
time: 514ms
memory: 155464kb

input:

639325794 599818

output:

599818
354529
240027
443750
494666
197610
194138
349071
129907
91388
322849
321759
270481
589353
326592
4183
82034
402985
598445
515386
418786
246691
233931
240064
148922
79785
36982
433698
152261
376887
361080
546062
163066
439769
90806
250158
267803
129995
356545
78246
355443
360147
363446
134618
...

result:

ok Accepted.

Test #28:

score: 15
Accepted
time: 836ms
memory: 173328kb

input:

514552014 904000

output:

904000
140946
658711
798848
178138
544209
233792
225810
92905
434089
627031
574663
218501
227583
630774
308365
86003
707167
7340
105949
722968
550873
77876
227140
240776
383967
102228
217225
456443
665262
850244
743951
215271
467248
394988
554340
434177
571985
202581
382428
659625
664329
667628
4388...

result:

ok Accepted.

Subtask #8:

score: 15
Accepted

Dependency #5:

100%
Accepted

Dependency #7:

100%
Accepted

Test #29:

score: 15
Accepted
time: 138ms
memory: 125528kb

input:

4043938008620250853548463463670539178824136101118676039998249773600296234199890542107734673644890238 182956

output:

182956
123162
26888
77804
125284
108043
27057
73531
125790
165065
91543
102417
120903
172491
23753
181583
128032
180635
148826
98524
1924
69894
8473
33055
93561
19049
58600
16836
96033
21868
129200
22907
39187
119912
92359
88312
38387
171523
150787
91871
85159
15282
3401
164842
172054
95202
149785
1...

result:

ok Accepted.

Test #30:

score: 15
Accepted
time: 325ms
memory: 139692kb

input:

6809505726107869121835226914314324742765939751165985001014682212595145094113574992502730535886215434 358074

output:

358074
233081
112785
108196
252922
14082
107327
40990
266661
300908
81105
161241
80015
28737
356701
347609
84848
303150
323944
273642
177042
4947
208173
194167
87355
268679
233718
191954
271151
304318
119336
135143
198025
124663
267477
26059
170012
8414
114801
260277
113699
121702
118403
347172
1373...

result:

ok Accepted.

Test #31:

score: 15
Accepted
time: 955ms
memory: 181056kb

input:

2263258607536236028437491678008 1000000

output:

1000000
754711
236946
15972
274138
15714
640209
329792
188905
314501
530089
723031
323583
670663
726774
103340
404365
803167
182003
201949
818968
173876
646873
323140
336776
479967
66830
198228
313225
946244
761262
839951
311271
490988
563248
530177
667985
650340
298581
478428
78505
763628
760329
53...

result:

ok Accepted.

Test #32:

score: 15
Accepted
time: 939ms
memory: 182048kb

input:

36212137720579776454999866846484 1000000

output:

1000000
754711
236946
15972
274138
640209
15714
329792
188905
314501
530089
723031
323583
670663
726774
103340
803167
404365
182003
201949
818968
173876
646873
479967
336776
323140
761262
198228
313225
66830
946244
839951
311271
490988
563248
530177
298581
667985
650340
478428
78505
763628
760329
53...

result:

ok Accepted.