QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#792119#9275. Integer Number Formatbulijiojiodibuliduo#AC ✓152ms114136kbC++171.6kb2024-11-29 00:10:042024-11-29 00:10:05

Judging History

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

  • [2024-11-29 00:10:05]
  • 评测
  • 测评结果:AC
  • 用时:152ms
  • 内存:114136kb
  • [2024-11-29 00:10:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1111111;
const int inf=1<<30;
short pre[N][17];
int dp[N][17],cnt[N];
int x,y,n;
int main() {
	scanf("%d%d%d",&x,&y,&n);
	rep(i,0,n) {
		int a;
		scanf("%d",&a),cnt[a-x]+=1;
	}
	y-=x;
	for (int i=1;i<=y+70000;i++)
		cnt[i]+=cnt[i-1];
	int ans=inf,anso=-1;;
	for (int i=0;i<=y+70000;i++) {
		dp[i][0]=inf;
		for (int j=1;j<=16;j++) {
			dp[i][j]=inf;
			for (int g=0;g<=4;g++) {
				int v=inf;
				if (i-(1<<(4*g))<0) {
					if (j==1) v=cnt[i]*(g+1);
				} else {
					v=dp[i-(1<<(4*g))][j-1]+(cnt[i]-cnt[i-(1<<(4*g))])*(g+1);
				}
				if (v<dp[i][j]) {
					dp[i][j]=v;
					pre[i][j]=g;
				}
			}
		}
		if (i>=y&&dp[i][16]<ans) {
			ans=dp[i][16];
			anso=i;
		}
	}
	per(i,1,17) {
		int g=pre[anso][i];
		printf("%d %d\n",g,anso-(1<<(4*g))+1+x);
		//reg.pb(mp(anso-(1<<(4*g))+1+x,g));
		anso=anso-(1<<(4*g));
	}
	//printf("%d\n",ans-n);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 14392kb

input:

0 15
16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

output:

0 15
0 14
0 13
0 12
0 11
0 10
0 9
0 8
0 7
0 6
0 5
0 4
0 3
0 2
0 1
0 0

result:

ok Successful 0

Test #2:

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

input:

-128 127
4
1 0 -1 0

output:

1 114
1 98
1 82
1 66
1 50
1 34
1 18
1 2
0 1
0 0
0 -1
0 -2
0 -3
0 -4
0 -5
2 -261

result:

ok Successful 0

Test #3:

score: 0
Accepted
time: 10ms
memory: 14620kb

input:

1 1
1
1

output:

0 16
0 15
0 14
0 13
0 12
0 11
0 10
0 9
0 8
0 7
0 6
0 5
0 4
0 3
0 2
0 1

result:

ok Successful 0

Test #4:

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

input:

0 255
16
0 16 32 48 64 80 96 112 128 144 160 176 192 208 232 248

output:

1 240
1 224
1 208
1 192
1 176
1 160
1 144
1 128
1 112
1 96
1 80
1 64
1 48
1 32
1 16
1 0

result:

ok Successful 16

Test #5:

score: 0
Accepted
time: 10ms
memory: 14312kb

input:

0 255
19
0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 255

output:

2 16
0 15
0 14
0 13
0 12
0 11
0 10
0 9
0 8
0 7
0 6
0 5
0 4
0 3
0 2
1 -14

result:

ok Successful 5

Test #6:

score: 0
Accepted
time: 10ms
memory: 14316kb

input:

635261933 635262132
19
635261951 635261970 635261950 635261989 635261954 635262006 635261986 635262007 635262008 635261969 635261995 635261961 635262004 635261963 635261976 635261970 635261958 635262013 635261937

output:

2 635262009
0 635262008
0 635262007
0 635262006
0 635262005
0 635262004
0 635262003
1 635261987
1 635261971
0 635261970
0 635261969
0 635261968
1 635261952
0 635261951
0 635261950
2 635261694

result:

ok Successful 12

Test #7:

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

input:

-176345389 -176344390
28
-176345066 -176344773 -176344764 -176345129 -176345228 -176345161 -176344764 -176345068 -176344769 -176344769 -176345224 -176344771 -176345233 -176344771 -176345214 -176345088 -176344770 -176345182 -176344766 -176344772 -176345104 -176344762 -176345275 -176344771 -176345247 ...

output:

3 -176344752
1 -176344768
0 -176344769
0 -176344770
0 -176344771
0 -176344772
0 -176344773
1 -176344789
1 -176344805
2 -176345061
1 -176345077
1 -176345093
1 -176345109
1 -176345125
1 -176345141
2 -176345397

result:

ok Successful 31

Test #8:

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

input:

-706505827 -706435952
15
-706502575 -706454600 -706463715 -706497431 -706503863 -706436020 -706502695 -706500720 -706436181 -706436169 -706505814 -706505814 -706441262 -706436072 -706503420

output:

2 -706436068
1 -706436084
1 -706436100
1 -706436116
1 -706436132
1 -706436148
1 -706436164
1 -706436180
0 -706436181
4 -706501717
3 -706505813
0 -706505814
0 -706505815
0 -706505816
0 -706505817
1 -706505833

result:

ok Successful 36

Test #9:

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

input:

437879511 437948260
11248
437898635 437888999 437885893 437937910 437922424 437890860 437888956 437903620 437901852 437888441 437905647 437881483 437880747 437884389 437940136 437918405 437912167 437936416 437911925 437880728 437884437 437880912 437914419 437896439 437922129 437930113 437946917 4379...

output:

4 437940943
3 437936847
3 437932751
3 437928655
3 437924559
3 437920463
3 437916367
3 437912271
3 437908175
3 437904079
3 437899983
3 437895887
3 437891791
3 437887695
3 437883599
3 437879503

result:

ok Successful 34976

Test #10:

score: 0
Accepted
time: 9ms
memory: 16436kb

input:

-585860336 -585850337
63
-585858281 -585858284 -585856372 -585853166 -585854142 -585853141 -585853167 -585855869 -585850885 -585858178 -585858268 -585853168 -585858253 -585858273 -585858210 -585853281 -585853167 -585854554 -585851396 -585853121 -585853165 -585858268 -585858177 -585858252 -585853837 ...

output:

3 -585853035
2 -585853291
2 -585853547
2 -585853803
2 -585854059
3 -585858155
1 -585858171
1 -585858187
1 -585858203
1 -585858219
1 -585858235
1 -585858251
0 -585858252
1 -585858268
1 -585858284
3 -585862380

result:

ok Successful 115

Test #11:

score: 0
Accepted
time: 18ms
memory: 24304kb

input:

790386968 790486967
333
790408603 790410858 790408759 790485090 790419913 790485075 790426878 790414047 790410950 790425070 790485079 790408530 790432804 790409246 790431473 790428211 790408974 790409386 790412686 790423641 790419955 790430469 790410873 790423649 790419922 790413993 790415166 790409...

output:

4 790435938
3 790431842
3 790427746
3 790423650
1 790423634
3 790419538
3 790415442
2 790415186
2 790414930
2 790414674
2 790414418
2 790414162
2 790413906
3 790409810
3 790405714
4 790340178

result:

ok Successful 898

Test #12:

score: 0
Accepted
time: 152ms
memory: 114136kb

input:

-924448066 -923448067
90673
-923698754 -923750960 -923771115 -924099252 -924162398 -923817192 -923952922 -924210676 -923778098 -923865229 -923741996 -923902374 -923670546 -923735725 -923752442 -924414963 -924162050 -923786475 -924057289 -924321891 -924006073 -923777325 -923546931 -924351131 -9237091...

output:

4 -923513602
4 -923579138
4 -923644674
4 -923710210
4 -923775746
4 -923841282
4 -923906818
4 -923972354
4 -924037890
4 -924103426
4 -924168962
4 -924234498
4 -924300034
4 -924365570
4 -924431106
4 -924496642

result:

ok Successful 362692

Test #13:

score: 0
Accepted
time: 143ms
memory: 114104kb

input:

107607372 108607371
100000
108402800 107734462 108151399 107908324 108138075 107821710 108113040 108582354 108302837 107848604 107962606 107985650 107959720 108250871 107708869 108352174 108178895 108499842 108547623 108135337 108219593 108289707 107808368 107665592 107724954 107863246 108044050 108...

output:

4 108541836
4 108476300
4 108410764
4 108345228
4 108279692
4 108214156
4 108148620
4 108083084
4 108017548
4 107952012
4 107886476
4 107820940
4 107755404
4 107689868
4 107624332
4 107558796

result:

ok Successful 400000

Test #14:

score: 0
Accepted
time: 27ms
memory: 22860kb

input:

-322002807 -321920587
4125
-321923788 -321973717 -321980528 -321995107 -322002304 -321995727 -321922865 -321932128 -322002143 -321994082 -321923382 -321940439 -321934687 -321967497 -322000791 -321962115 -321955671 -321992747 -322002544 -321939315 -322002184 -321999525 -321981914 -321996610 -32193736...

output:

3 -321922367
2 -321922623
2 -321922879
2 -321923135
2 -321923391
2 -321923647
3 -321927743
2 -321927999
4 -321993535
3 -321997631
2 -321997887
3 -322001983
2 -322002239
2 -322002495
2 -322002751
2 -322003007

result:

ok Successful 13691

Test #15:

score: 0
Accepted
time: 64ms
memory: 58148kb

input:

445369099 445760921
2210
445388095 445650072 445421201 445728507 445574057 445371150 445485821 445676840 445498130 445376456 445659746 445680617 445631986 445699953 445738336 445743105 445512585 445712362 445753740 445483695 445591468 445422153 445372409 445648361 445517777 445389757 445372840 44550...

output:

4 445730040
3 445725944
3 445721848
4 445656312
4 445590776
2 445590520
4 445524984
3 445520888
4 445455352
4 445389816
2 445389560
3 445385464
3 445381368
3 445377272
3 445373176
3 445369080

result:

ok Successful 8320

Test #16:

score: 0
Accepted
time: 74ms
memory: 68056kb

input:

-978992138 -978492139
15134
-978564795 -978924492 -978695966 -978501057 -978545856 -978668160 -978818191 -978660679 -978670558 -978605178 -978637429 -978882576 -978668151 -978925385 -978651989 -978719938 -978656512 -978671503 -978688035 -978875223 -978600048 -978638822 -978721059 -978652021 -9787862...

output:

4 -978524917
4 -978590453
3 -978594549
4 -978660085
3 -978664181
3 -978668277
3 -978672373
4 -978737909
3 -978742005
4 -978807541
3 -978811637
3 -978815733
3 -978819829
4 -978885365
4 -978950901
4 -979016437

result:

ok Successful 58387

Test #17:

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

input:

806336884 806436883
100000
806408190 806370346 806434531 806393213 806387657 806354401 806376901 806417371 806389350 806359375 806422807 806411520 806390412 806395082 806392170 806378206 806378480 806393104 806358259 806379850 806407975 806410493 806384171 806406318 806394253 806393620 806380309 806...

output:

4 806415035
3 806410939
3 806406843
3 806402747
3 806398651
3 806394555
3 806390459
3 806386363
3 806382267
3 806378171
3 806374075
3 806369979
3 806365883
3 806361787
3 806357691
4 806292155

result:

ok Successful 332662

Test #18:

score: 0
Accepted
time: 106ms
memory: 86356kb

input:

851582603 852282602
89904
851709673 851814815 852086552 851998730 852241437 851854141 852035478 851784536 851908759 851683522 851952143 851686361 851584480 852096755 851802720 852122287 851895393 851976679 852111555 852193202 852073134 851897322 851608532 851595640 851630901 851618839 852002214 8516...

output:

4 852250111
4 852184575
3 852180479
4 852114943
4 852049407
3 852045311
4 851979775
4 851914239
3 851910143
3 851906047
4 851840511
4 851774975
4 851709439
3 851705343
4 851639807
4 851574271

result:

ok Successful 355493

Test #19:

score: 0
Accepted
time: 109ms
memory: 84800kb

input:

138773043 139471183
100000
139026197 139412760 138983975 138945205 139087323 139189227 138822828 139116072 138966719 138994599 139291863 138887619 138858899 138885504 139034757 139290557 139007447 139345798 139022693 139059439 138854536 139238331 139057589 139243160 139219463 139420846 138928945 138...

output:

4 139448880
4 139383344
4 139317808
4 139252272
4 139186736
4 139121200
4 139055664
4 138990128
4 138924592
4 138859056
3 138854960
3 138850864
3 138846768
3 138842672
4 138777136
3 138773040

result:

ok Successful 395255

Test #20:

score: 0
Accepted
time: 63ms
memory: 58920kb

input:

357891521 358308590
52200
358204812 358301447 357893591 358114850 358308064 358130919 358086104 357895398 357896902 358303842 358118141 357969182 357947473 358305188 358247063 358172687 358284923 358090049 357891736 358074872 358192137 358030063 358306730 358220247 358119029 358047539 358111905 3581...

output:

3 358305629
3 358301533
2 358301277
4 358235741
4 358170205
4 358104669
2 358104413
4 358038877
1 358038861
3 358034765
4 357969229
2 357968973
3 357964877
4 357899341
3 357895245
3 357891149

result:

ok Successful 180569

Extra Test:

score: 0
Extra Test Passed