QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#792152#9280. New Randomized Gobulijiojiodibuliduo#AC ✓344ms39176kbC++174.1kb2024-11-29 01:35:592024-11-29 01:36:00

Judging History

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

  • [2024-11-29 01:36:00]
  • 评测
  • 测评结果:AC
  • 用时:344ms
  • 内存:39176kb
  • [2024-11-29 01:35:59]
  • 提交

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

template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint():v(0) {}
	mint(ll _v) { v = int((-MOD < _v && _v < MOD) ? _v : _v % MOD);
		if (v < 0) v += MOD; }
	bool operator==(const mint& o) const {
		return v == o.v; }
	friend bool operator!=(const mint& a, const mint& b) { 
		return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) { 
		return a.v < b.v; }
   
	mint& operator+=(const mint& o) { 
		if ((v += o.v) >= MOD) v -= MOD; 
		return *this; }
	mint& operator-=(const mint& o) { 
		if ((v -= o.v) < 0) v += MOD; 
		return *this; }
	mint& operator*=(const mint& o) { 
		v = int((ll)v*o.v%MOD); return *this; }
	mint& operator/=(const mint& o) { return (*this) *= inv(o); }
	friend mint pow(mint a, ll p) {
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans; }
	friend mint inv(const mint& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};

const int MOD=1000000007; 
using mi = mint<MOD,5>; // 5 is primitive root for both common mods

namespace simp {
	vector<mi> fac,ifac,invn;
	void check(int x) {
		if (fac.empty()) {
			fac={mi(1),mi(1)};
			ifac={mi(1),mi(1)};
			invn={mi(0),mi(1)};
		}
		while (SZ(fac)<=x) {
			int n=SZ(fac),m=SZ(fac)*2;
			fac.resize(m);
			ifac.resize(m);
			invn.resize(m);
			for (int i=n;i<m;i++) {
				fac[i]=fac[i-1]*mi(i);
				invn[i]=mi(MOD-MOD/i)*invn[MOD%i];
				ifac[i]=ifac[i-1]*invn[i];
			}
		}
	}
	mi gfac(int x) {
		assert(x>=0);
		check(x); return fac[x];
	}
	mi ginv(int x) {
		assert(x>0);
		check(x); return invn[x];
	}
	mi gifac(int x) {
		assert(x>=0);
		check(x); return ifac[x];
	}
	mi binom(int n,int m) {
		if (m < 0 || m > n) return mi(0);
		return gfac(n)*gifac(m)*gifac(n - m);
	}
	mi binombf(int n,int m) {
		if (m < 0 || m > n) return mi(0);
		if (m>n-m) m=n-m;
		mi p=1,q=1;
		for (int i=1;i<=m;i++) p=p*(n+1-i),q=q*i;
		return p/q;
	}
}


const int N=3010000;

int n;
ll l,x[N];
mi pw[N];
mi single() {
	mi ans=0;
	ans+=1;
	int r=0;
	rep(i,0,n) {
		while (x[r]<x[i]+l) r++;
		//printf("%d %d\n",i,r);
		ans+=pw[r-i-1];
	}
	//printf("? %d\n",(int)ans);
	return ans;
}
int cnt(ll l,ll r) {
	int cc=lower_bound(x,x+3*n,r+1)-lower_bound(x,x+3*n,l);
	return cc;
}
mi dbl() {
	mi ans=0;
	int r=0;
	rep(i,0,n) {
		while (x[r]<x[i]+l) r++;
		assert(r<=i+n-1);
		// r .. i+n-1 ->R
		ans+=1;
		ans+=pw[cnt(x[i+n-1]-l+1,x[r]-1)]-1;
		ans+=pw[cnt(x[i+n-1]+1,x[r]+l-1)-(x[i+n]<x[r]+l)]-1;
	}
	return ans;
}
int main() {
	scanf("%d%lld",&n,&l);
	pw[0]=1;
	rep(i,1,n+1) pw[i]=pw[i-1]*2;
	rep(i,0,n) {
		scanf("%lld",&x[i]);
		x[i]=x[i]*2;
	}
	sort(x,x+n);
	rep(i,0,n+n) x[i+n]=x[i]+2*l;
	rep(i,0,n) if (x[i+n-1]-x[i]<l) {
		puts("0");
		return 0;
	}
	mi pr=pw[n]-2*single()+dbl();
	pr/=pw[n];
	printf("%d\n",(int)pr);
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 16344kb

input:

4 100
0 30 50 80

output:

125000001

result:

ok 1 number(s): "125000001"

Test #2:

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

input:

8 100
1 12 34 45 51 84 88 92

output:

515625004

result:

ok 1 number(s): "515625004"

Test #3:

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

input:

6 123
1 21 41 61 81 101

output:

562500004

result:

ok 1 number(s): "562500004"

Test #4:

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

input:

1 1000
999

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

2 999
123 456

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

3 400
100 200 300

output:

0

result:

ok 1 number(s): "0"

Test #7:

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

input:

4 500
100 200 300 401

output:

0

result:

ok 1 number(s): "0"

Test #8:

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

input:

5 600
100 200 300 400 500

output:

125000001

result:

ok 1 number(s): "125000001"

Test #9:

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

input:

5 599
100 200 300 400 500

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

5 600
100 200 300 400 501

output:

562500004

result:

ok 1 number(s): "562500004"

Test #11:

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

input:

6 311
2 25 87 117 251 269

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

10 49
0 7 12 13 17 19 22 28 30 38

output:

527343754

result:

ok 1 number(s): "527343754"

Test #13:

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

input:

11 39
0 1 9 15 19 21 23 25 28 37 38

output:

62500001

result:

ok 1 number(s): "62500001"

Test #14:

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

input:

12 39
10 12 15 16 20 23 24 25 26 30 31 38

output:

596679692

result:

ok 1 number(s): "596679692"

Test #15:

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

input:

12 100
25 26 29 33 36 45 46 51 53 63 72 74

output:

0

result:

ok 1 number(s): "0"

Test #16:

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

input:

13 100
0 1 3 4 5 10 15 19 21 36 40 44 48

output:

0

result:

ok 1 number(s): "0"

Test #17:

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

input:

13 100
50 53 55 61 72 78 79 84 86 89 96 97 98

output:

0

result:

ok 1 number(s): "0"

Test #18:

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

input:

14 100
20 22 24 26 29 35 39 88 91 93 96 97 98 99

output:

0

result:

ok 1 number(s): "0"

Test #19:

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

input:

10 100000
83731 12 47801 73162 33421 683 68402 26623 30898 89670

output:

640625005

result:

ok 1 number(s): "640625005"

Test #20:

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

input:

11 100000
47884 60925 32913 21 40497 66832 47729 25573 14377 46665 48395

output:

982421882

result:

ok 1 number(s): "982421882"

Test #21:

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

input:

12 100000
99253 99620 99843 99325 99446 99599 99331 99100 99219 99725 99605 99969

output:

0

result:

ok 1 number(s): "0"

Test #22:

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

input:

12 100000
36870 28725 62550 55973 55233 42504 27024 51420 71272 25000 30760 53628

output:

0

result:

ok 1 number(s): "0"

Test #23:

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

input:

13 100000
36464 14518 35422 804 30649 0 34318 20786 31607 38386 6204 37309 823

output:

0

result:

ok 1 number(s): "0"

Test #24:

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

input:

13 100000
81842 59901 98543 84145 94775 75783 90529 66356 92049 50000 81399 76436 53816

output:

0

result:

ok 1 number(s): "0"

Test #25:

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

input:

14 100000
29275 86103 27224 34970 39991 20000 20737 36082 94417 99598 97862 23565 24511 88214

output:

0

result:

ok 1 number(s): "0"

Test #26:

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

input:

10 1000000000
139226232 668475559 922085044 220091782 123456 818628396 44036125 553403492 812857650 839136426

output:

839843756

result:

ok 1 number(s): "839843756"

Test #27:

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

input:

11 1000000000
172760648 365249261 133335064 294349090 654321 756289903 349295556 795799787 209082869 140195146 664048161

output:

492187504

result:

ok 1 number(s): "492187504"

Test #28:

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

input:

12 1000000000
999999688 999999486 999999200 999999335 999999100 999999981 999999994 999999857 999999983 999999271 999999694 999999493

output:

0

result:

ok 1 number(s): "0"

Test #29:

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

input:

12 1000000000
563158403 399272404 532105181 601859823 511157508 379560553 460622517 250000000 599012385 567088956 485970030 562853845

output:

0

result:

ok 1 number(s): "0"

Test #30:

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

input:

13 1000000000
335681989 0 438844751 314123679 43811339 169139927 361426050 387540822 133618143 32561635 416229353 373626164 211988573

output:

0

result:

ok 1 number(s): "0"

Test #31:

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

input:

13 1000000000
795344186 500000000 524995168 911526905 878682307 809921706 983524938 910268610 531488865 710659981 540822922 728777284 659199202

output:

0

result:

ok 1 number(s): "0"

Test #32:

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

input:

14 1000000000
269307161 366936741 376579409 398361917 920935834 339001928 266622296 200000000 223728298 308568589 868198001 231512519 212667619 318034818

output:

0

result:

ok 1 number(s): "0"

Test #33:

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

input:

1000 999999999
517341763 254363305 157388706 863599973 282702320 379130622 961999807 144790113 727123068 254914475 983045219 597792994 643623913 337862207 687784339 269138275 755794215 222421909 374204542 890198049 255046091 602746280 587018192 170126190 418157794 829438581 324576209 10670219 693428...

output:

795937347

result:

ok 1 number(s): "795937347"

Test #34:

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

input:

10000 1000000000
273992017 121906911 239851617 28490032 379370164 966220957 785153807 838418025 932574226 337631137 978921021 249464281 298798692 986504132 864274094 248305016 300875975 284978798 489469042 200341245 727771457 703207360 390755238 736074461 36069904 397989101 316632394 94327856 263909...

output:

931365356

result:

ok 1 number(s): "931365356"

Test #35:

score: 0
Accepted
time: 35ms
memory: 19856kb

input:

100000 1000000000
482395555 321462031 211649713 748115732 74485241 92553042 792500447 964461134 733337110 457577156 700835246 109797716 465177369 741916132 300367462 541467361 76482612 968691993 396593414 133080413 66299782 157264279 411090049 894229656 474545463 196501661 503026624 620607068 269071...

output:

212114913

result:

ok 1 number(s): "212114913"

Test #36:

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

input:

200000 1000000000
752724769 684089249 258986129 547562080 513119936 462793352 126283142 315616530 485064342 923172110 410418139 658027714 704384985 207012686 209782897 723984152 218205183 794852357 1887310 387990606 456042135 365400222 550864553 446762659 614490881 435494072 562719857 921859125 9704...

output:

529956668

result:

ok 1 number(s): "529956668"

Test #37:

score: 0
Accepted
time: 133ms
memory: 25524kb

input:

400000 1000000000
33193124 972988405 177211361 679617260 935450608 700616393 235451869 938662946 484592784 528126147 283204818 91942446 396374149 593243152 502399289 491795908 939391255 445481679 123682953 516947934 326189039 345814118 97888630 293006833 375960910 25979976 825444537 162058083 858385...

output:

428201298

result:

ok 1 number(s): "428201298"

Test #38:

score: 0
Accepted
time: 235ms
memory: 33576kb

input:

700000 1000000000
817664213 787154281 242350839 307312470 833468706 41900155 766249043 70983876 436626092 682382246 379162585 759074366 940703116 428971143 834010432 240403544 966563785 42966786 12204400 914638089 25435248 551219720 26155112 385329648 727727673 587803824 131561263 224660331 32189018...

output:

144997443

result:

ok 1 number(s): "144997443"

Test #39:

score: 0
Accepted
time: 344ms
memory: 39000kb

input:

1000000 1000000000
312831321 281483910 659362349 721879931 648331892 287070348 257813115 860613633 754130193 771831182 429069519 854379219 525715717 47961888 459341920 891857600 826548053 141224985 112949853 848665354 595785973 694547816 778333778 883805664 218703568 441242515 672874011 756995161 37...

output:

719302441

result:

ok 1 number(s): "719302441"

Test #40:

score: 0
Accepted
time: 340ms
memory: 39012kb

input:

1000000 999999999
308451215 202902507 481611147 870332837 803727333 700857201 221866489 131265376 583790996 891116894 884703940 785156513 877787179 600876261 225542074 689846259 925352020 829326557 119607851 493319250 205626543 254853553 747865961 919349566 171399436 75691829 237083458 480895386 152...

output:

591820482

result:

ok 1 number(s): "591820482"

Test #41:

score: 0
Accepted
time: 340ms
memory: 39008kb

input:

1000000 999999999
586305801 562700526 551909689 958325165 681800612 187256936 273040963 815458247 587833112 694029413 913842032 789516837 201732801 387746498 639762683 977830357 843828127 359254969 567569964 775285461 331452421 595267412 164240457 528978129 910300270 430990490 616689309 578176238 98...

output:

459268216

result:

ok 1 number(s): "459268216"

Test #42:

score: 0
Accepted
time: 136ms
memory: 39172kb

input:

1000000 999999998
475485927 450068905 308689708 475924042 562116197 469096684 399973949 391091182 595430900 423803995 581324288 460669529 387683751 522220126 359377386 534565082 528324089 592491219 433444810 514620658 334327882 365087645 402449395 382957167 538346092 497646167 567567538 335112924 57...

output:

0

result:

ok 1 number(s): "0"

Test #43:

score: 0
Accepted
time: 138ms
memory: 39176kb

input:

1000000 999999997
704946137 935297482 782589572 876470254 985580704 999556161 772635865 814850049 837054195 977933074 944996772 791726343 841899458 790618088 799554746 984271886 809229206 841488928 991582451 970267269 746765420 703548877 767370566 751264656 786568165 732773621 913809049 953318478 87...

output:

0

result:

ok 1 number(s): "0"

Test #44:

score: 0
Accepted
time: 329ms
memory: 39000kb

input:

1000000 1000000000
895490364 686809180 968108323 165444094 734553719 855084181 776116814 238850869 978149487 205580032 115131852 427306268 148824939 756594058 213619984 693649693 729988903 153832003 747228457 336583761 267393690 376927631 405363292 702872518 766555279 698744399 864126336 697068235 9...

output:

538718938

result:

ok 1 number(s): "538718938"

Test #45:

score: 0
Accepted
time: 239ms
memory: 39032kb

input:

1000000 1000000000
977344624 843954994 834864048 523240631 993765741 769326712 544606348 720711423 494744680 738774241 937942470 831465857 591342654 607550956 778638269 966702116 813930714 598233797 597942868 732521423 690817876 984568963 647515703 963348536 668134408 623541472 986453273 562069228 5...

output:

951516328

result:

ok 1 number(s): "951516328"

Test #46:

score: 0
Accepted
time: 223ms
memory: 38992kb

input:

1000000 1000000000
799063768 960539906 837106860 943659688 921282214 833032932 980496892 775386108 998719871 803483592 709079444 750496020 915373810 827524710 975469169 991370163 798889509 849981524 712479859 928004016 770972864 942157332 847865462 861591148 780686341 858265384 960847908 929106563 8...

output:

257998230

result:

ok 1 number(s): "257998230"

Test #47:

score: 0
Accepted
time: 332ms
memory: 39064kb

input:

1000000 1000000
972708 980578 623109 889436 838852 7706 838060 920768 222478 96797 399982 480588 560692 460025 825920 55130 172810 442446 619042 524980 895054 299731 813374 536669 396283 503325 601945 849762 970864 780172 203487 753402 246467 544280 697766 41409 731318 157455 141671 463066 341136 12...

output:

659539598

result:

ok 1 number(s): "659539598"

Test #48:

score: 0
Accepted
time: 336ms
memory: 39004kb

input:

1000000 2000000
76350 635302 1378039 628413 1560968 1580769 1169635 124926 1725384 51244 641499 972612 1689765 1783609 666239 1593555 1618857 939208 1602750 1414053 332377 104281 1494558 880427 2488 9772 1853256 804349 635791 1089683 1028132 194731 1352009 1456985 1644823 960466 286705 1490716 27262...

output:

995549230

result:

ok 1 number(s): "995549230"

Test #49:

score: 0
Accepted
time: 323ms
memory: 39012kb

input:

1000000 1100000
1078488 689189 342862 761355 176966 27254 708601 370760 536412 789992 831750 416310 55373 814269 547028 904055 298878 995533 174829 438698 526868 923952 909227 771709 434123 304498 352483 243336 304628 319000 515411 1021447 482369 280952 25276 1072720 563929 443985 1095929 194949 361...

output:

15049302

result:

ok 1 number(s): "15049302"

Test #50:

score: 0
Accepted
time: 326ms
memory: 38980kb

input:

1000000 1000100
241687 815694 292601 926010 173177 649900 921987 309687 326571 471118 337953 730955 673264 986551 287018 602135 865558 951938 709510 170884 996850 543326 321517 392913 415082 858022 996896 263112 784703 196430 392266 391247 509137 617502 503610 877282 49889 905165 83039 249063 701754...

output:

489704165

result:

ok 1 number(s): "489704165"

Extra Test:

score: 0
Extra Test Passed