QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#784014 | #9649. problem | Arghariza | 100 ✓ | 724ms | 46240kb | C++14 | 2.8kb | 2024-11-26 12:40:13 | 2024-11-26 12:40:13 |
Judging History
answer
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define R(i, x, y) for (int i = (x); i >= (y); i--)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
bool Mbe;
const int K = 20;
const int N = 1e5 + 5;
const int P = 1e9 + 7;
int n, k, m;
int C[K][K], ans[N][K], pw[N][K];
struct BIT {
int o;
int t[N];
void c(int _o) {
o = _o;
F (i, 1, n + 1) {
t[i] = 0;
}
}
int lb(int x) {
return x & -x;
}
void u(int x, int y) {
for (int i = x; i && i <= n + 1; i += o * lb(i)) {
(t[i] += y) %= P;
}
}
int q(int x) {
int res = 0;
for (int i = x; i && i <= n + 1; i -= o * lb(i)) {
(res += t[i]) %= P;
}
return res;
}
} T1, T2, T3, T4;
struct Q {
int l, i, o;
Q () { }
Q (int _l, int _i, int _o) : l(_l), i(_i), o(_o) { }
};
vector<Q> q1[N], q2[N], q3[N], q4[N];
vector<int> s[N];
void solve() {
cin >> n >> k >> m;
C[0][0] = 1;
F (i, 1, k) {
C[i][0] = 1;
F (j, 1, i) {
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
}
}
F (i, 1, n + 1) {
pw[i][0] = 1;
F (j, 1, k) {
pw[i][j] = 1ll * pw[i][j - 1] * i % P;
}
}
F (i, 1, n) {
int l, r;
cin >> l >> r, r++;
s[r].eb(l);
}
F (i, 1, m) {
int l, r;
cin >> l >> r, r++;
q1[r].eb(Q(l, i, 1));
q2[r].eb(Q(l + 1, i, 1));
q2[r].eb(Q(r + 1, i, P - 1));
q3[r - 1].eb(Q(l, i, 1));
q3[l - 1].eb(Q(l, i, P - 1));
q4[r - 1].eb(Q(l + 1, i, 1));
}
F (i, 0, k) {
T1.c(1), T2.c(-1), T3.c(1), T4.c(-1);
R (r, n + 1, 1) {
for (int l : s[r]) {
T1.u(l, 1);
T2.u(l, pw[l][k - i]);
}
for (Q j : q1[r]) {
(ans[j.i][i] += 1ll * j.o * pw[r][i] % P * pw[j.l][k - i] % P * T1.q(j.l) % P) %= P;
}
for (Q j : q2[r]) {
(ans[j.i][i] += 1ll * j.o * pw[r][i] % P * T2.q(j.l) % P) %= P;
}
}
F (r, 1, n + 1) {
for (int l : s[r]) {
T3.u(l, pw[r][i]);
T4.u(l, 1ll * pw[l][k - i] * pw[r][i] % P);
}
for (Q j : q3[r]) {
(ans[j.i][i] += 1ll * j.o * pw[j.l][k - i] % P * T3.q(j.l) % P) %= P;
}
for (Q j : q4[r]) {
(ans[j.i][i] += 1ll * j.o * T4.q(j.l) % P) %= P;
}
}
}
F (i, 1, m) {
int res = 0;
F (j, 0, k) {
(res += 1ll * C[k][j] * (((k - j) & 1) ? (P - 1) : 1) % P * ans[i][j] % P) %= P;
}
cout << res << '\n';
}
}
bool Med;
int main() {
// FIO("");
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cerr << (&Mbe - &Med) / 1048576.0 << " MB\n";
int T = 1;
// cin >> T;
while (T--) solve();
cerr << (int)(1e3 * clock() / CLOCKS_PER_SEC) << " ms\n";
return 0;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 4
Accepted
time: 11ms
memory: 18832kb
input:
1997 13 2000 173 1173 1390 1848 339 1283 846 1672 644 791 898 1884 68 79 29 907 298 641 835 1004 564 1315 262 332 826 1380 1067 1186 460 1355 1447 1635 290 589 1094 1851 190 1038 653 1932 349 733 1810 1883 147 1942 207 566 12 60 56 1819 423 1274 1603 1966 297 803 522 524 1510 1940 492 602 1397 1669 ...
output:
998807601 841013640 457869797 81474577 490417411 619095756 20635329 285520781 318010284 274424466 678001159 874898912 196102062 66870119 136133803 605596352 674159599 975855361 380556010 822290963 699523714 590735959 20565146 147522405 884181228 843669774 765883820 119995128 243367243 467385235 2109...
result:
ok 2000 lines
Test #2:
score: 4
Accepted
time: 10ms
memory: 19092kb
input:
1995 14 2000 639 1231 475 679 12 179 719 1451 335 1415 1135 1460 954 1346 1172 1278 621 843 618 954 649 1076 161 1884 359 1597 1006 1347 1048 1768 875 1892 1311 1621 71 1435 177 679 393 597 403 1155 54 1028 353 1426 275 1555 377 1609 1456 1682 430 1607 866 1547 248 1224 181 362 251 1966 1024 1243 58...
output:
420910086 420354253 913013988 310909440 290474563 789379887 26194098 972174427 898296798 523721041 229868346 44579409 814114130 450841640 460057052 555749038 69008129 252382757 910230402 446559764 560942847 52737403 925895621 441001367 768886662 132793891 239090368 625050642 936666823 83548944 39659...
result:
ok 2000 lines
Test #3:
score: 4
Accepted
time: 145ms
memory: 46156kb
input:
100000 1 99991 65936 91366 18231 94904 78136 98982 5923 55572 56154 56976 16519 51688 27114 85795 13841 66508 53501 64992 55262 85456 45291 51763 9150 22167 40160 71640 8594 93216 41460 54569 50758 87075 37891 46819 52457 92063 69325 93799 60846 98645 36339 37980 11741 87836 77374 95597 28033 35884 ...
output:
46000641 24776743 620544527 913842935 169002561 675738489 73072831 560721295 483332973 408552663 253124971 365517852 302904916 134220778 39904343 830114940 776124703 151036162 35431144 738931235 350274621 17930024 907124224 8385142 455565500 543314552 313505715 497512357 590804614 52391858 50761383 ...
result:
ok 99991 lines
Test #4:
score: 4
Accepted
time: 166ms
memory: 46156kb
input:
100000 1 99991 70681 88140 67484 73681 15674 17415 40078 92459 15898 50120 16610 53929 75031 88822 14066 61564 29232 84223 35743 49204 19675 59272 19358 36024 32317 33158 74824 75761 41091 94834 30508 68857 8299 48927 22137 87187 2539 13740 9651 92567 3498 79569 48919 69930 68914 75113 85947 88542 4...
output:
441273681 903457544 179779393 640460131 783425178 804491970 254780582 365509594 556348341 585631136 230281368 59331057 867468105 796955262 499065169 398871151 30569385 766529405 208297 580406644 294601572 62759451 163353833 444679117 489204718 367752770 122304576 528522706 845542178 205298298 221435...
result:
ok 99991 lines
Test #5:
score: 4
Accepted
time: 177ms
memory: 46240kb
input:
100000 2 99993 2296 57055 26675 72223 9679 27823 62383 76529 16853 39940 10325 20898 19366 69708 53993 56313 77391 96491 13978 50720 3786 37923 48673 94619 5358 75806 46280 87238 18687 40867 35935 96769 61227 73365 51789 87609 4062 63235 15544 95143 4474 18830 80698 93112 26529 33118 21662 97902 421...
output:
641656749 336929367 719211749 359588668 343452812 120223418 682556425 310755514 917680672 354785116 125593580 900924846 452369943 179218835 323474610 379462307 767837537 837674074 159723235 475947839 138734498 406571144 663486307 611597098 981933763 205593823 15170662 611199652 625987617 514602607 1...
result:
ok 99993 lines
Test #6:
score: 4
Accepted
time: 179ms
memory: 46188kb
input:
100000 2 99997 82850 86533 21477 72747 44515 73151 43388 99270 380 19701 10415 14627 7327 67283 3871 25907 8113 60732 14469 61755 11296 79602 4827 86722 67963 99579 1551 89254 51137 62105 40201 78226 55827 75474 84980 86518 67108 96450 955 11244 46063 53285 27109 33270 12634 50773 12280 83265 1874 5...
output:
307395947 557542298 791145631 940204275 814075606 348094403 950847414 195610629 980310898 549822108 924372036 819060377 668212280 945135153 472228625 431019218 177197174 691644365 3666825 727709679 824443257 842800986 498379909 735971253 546710562 635982461 116264847 694285704 871595361 658381636 48...
result:
ok 99997 lines
Test #7:
score: 4
Accepted
time: 193ms
memory: 46220kb
input:
100000 2 99992 48714 63403 70730 75716 77838 95799 70748 77544 79445 93524 10505 16868 34546 39392 6334 75622 24973 38835 78217 85341 53985 94613 23547 33283 25528 93800 58967 89124 14035 37216 83633 87813 10287 58939 15055 21248 53857 54345 19069 51536 20443 44548 85297 94353 9609 26741 46002 79028...
output:
949409790 476773944 730396608 268428716 506013176 620631494 11993651 62520145 879984056 844614294 922595589 222713814 772755827 648935691 504756250 304159294 422915429 291032226 408129119 691590987 168596040 706051932 607686216 719939008 944222626 179579541 429284250 581820279 191120618 117563948 94...
result:
ok 99992 lines
Test #8:
score: 4
Accepted
time: 198ms
memory: 46236kb
input:
100000 2 99992 45488 68149 21789 63088 49821 79788 11699 74930 39188 53963 10597 43299 72165 87309 55884 78248 36854 97726 33119 66158 2122 19856 47140 66459 55317 74581 5983 56291 33261 47486 30104 59770 20835 45100 55978 77834 41583 43967 12992 67637 10329 79090 43486 88141 33853 73553 36620 64391...
output:
34747980 933826548 727542956 350560593 537754993 774432713 741953700 5806652 861485328 796167211 872076854 331271012 984817471 477000664 227039615 608288617 166923625 264914164 742119382 369296386 927891377 615714153 797868673 188519988 168181071 278456109 563079521 51438353 708016629 568954179 6932...
result:
ok 99992 lines
Test #9:
score: 4
Accepted
time: 189ms
memory: 46172kb
input:
100000 2 99992 14111 31862 566 12341 45996 96480 11816 54367 14403 98932 12839 19198 35226 75192 27634 58675 34872 61966 48193 62610 9632 94240 76668 93701 49539 66738 56161 87592 861 76679 3202 15499 23948 38696 23412 75205 28820 77182 7930 98402 13544 76110 10187 49225 58097 96172 27238 60153 3097...
output:
633545272 767336021 659067854 326305761 2382807 621032140 309003774 382805 199626098 336669779 668182334 67774497 848215221 436626765 121009622 401166115 459289906 577429345 838369567 264409997 603836784 534463894 353607528 417297242 257127261 664757830 357708180 237885328 496497483 561130201 972463...
result:
ok 99992 lines
Test #10:
score: 4
Accepted
time: 176ms
memory: 46224kb
input:
100000 2 99997 18856 61339 3535 37403 17980 47764 15999 88522 25972 74842 6568 19288 37003 83143 6397 7896 34719 65594 4482 26359 17141 35919 40262 62684 24303 43760 23327 77712 43835 63201 57790 79338 73509 85844 5280 58141 48762 67293 16517 56735 50403 80703 43012 68375 16933 42984 45516 85152 591...
output:
365035455 606835551 94538819 138674861 167189812 90458209 330535734 418246305 232411781 992484031 346829331 852627210 470253506 775240010 987674641 147369581 471441147 988689230 95827545 158428017 85260979 540077726 994635790 729649172 330829024 402726591 524449725 830948453 54969849 202062893 65454...
result:
ok 99997 lines
Test #11:
score: 4
Accepted
time: 233ms
memory: 44012kb
input:
100000 7 99994 28 510 109 195 94 284 69 346 63 80 504 508 19 245 194 333 86 498 58 79 116 511 203 322 46 301 373 445 312 461 215 330 18 36 65 297 323 363 412 419 141 299 398 451 80 358 24 332 244 316 145 481 293 339 55 278 55 269 8 448 197 479 333 474 90 442 5 339 32 62 137 419 398 419 14 474 135 13...
output:
384285535 863045044 77140059 837167484 882191840 943857288 893067528 252185928 566746041 156478978 463805178 683545969 931322295 603126837 464382759 305748030 662757088 476032562 113752923 89974152 763627903 451158713 942443081 889013405 28919 322962123 945005402 440866343 919560391 529840421 434428...
result:
ok 99994 lines
Test #12:
score: 4
Accepted
time: 261ms
memory: 44088kb
input:
99998 8 100000 258 356 12 420 248 445 93 332 6 465 295 403 141 490 360 497 73 391 126 277 496 509 96 160 25 451 187 448 77 153 349 363 62 108 64 217 183 374 116 328 23 450 48 289 60 494 45 370 11 438 133 243 150 299 483 500 170 350 125 481 125 248 151 491 45 140 299 487 129 401 213 238 263 458 135 1...
output:
103987123 879009050 171786411 653721651 820890143 942230375 13386463 703545261 403653671 707688075 81513035 575541661 872667546 709878161 124525331 266226560 72707530 11191611 886067149 250384125 15362051 417484940 335627552 602761947 945732327 72421585 495352985 637165422 864309221 498378507 40215 ...
result:
ok 100000 lines
Test #13:
score: 4
Accepted
time: 191ms
memory: 45656kb
input:
100000 3 99999 32543 49636 35941 53122 39591 56695 6883 23920 42561 59721 16402 33474 42089 59282 54626 71682 69330 86526 82522 99681 47813 64898 31468 48577 23183 40210 56283 73377 41913 59104 27813 44937 24035 41053 17202 34256 37982 55149 58324 75441 51947 68980 69354 86547 81529 98641 18665 3572...
output:
292969726 520616929 234726132 469467957 966146438 988501337 143463148 301669316 165521142 540831621 613111354 535476228 335111815 122934367 204212988 389639773 477033942 128624188 115395164 263660691 971566117 989550434 582138146 816884448 649576334 95568705 909487477 858403704 821262686 959434840 6...
result:
ok 99999 lines
Test #14:
score: 4
Accepted
time: 226ms
memory: 45460kb
input:
100000 4 99994 43442 62691 13722 33004 48998 68198 11841 31095 28132 47426 79825 99019 27945 47234 14991 34298 56789 76010 37059 56283 17994 37286 80761 99923 15924 35207 25700 45000 58792 77966 42822 62070 55904 75102 51313 70577 17338 36634 33030 52263 26407 45702 38841 58087 48743 67950 4572 2377...
output:
804826713 856083253 653322493 91681975 198685199 173030450 310616174 124879018 283627225 812903270 177748828 188981264 699476811 583936158 158150079 245372565 538083835 412380223 582054226 684154979 710451507 204167508 156409491 928847111 517728082 905240399 927400500 575792018 91172908 973397309 84...
result:
ok 99994 lines
Test #15:
score: 4
Accepted
time: 260ms
memory: 45668kb
input:
99998 5 100000 54935 66393 67394 78811 36393 47848 28287 39745 64256 75655 3416 14837 62810 74237 15574 26961 27519 38957 12640 24021 34061 45544 81657 93046 29668 41110 60969 72385 39212 50669 10590 22036 21820 33237 75911 87318 50363 61837 85536 96972 16574 27978 27716 39155 43703 55155 52139 6360...
output:
141469878 200983698 93494910 113545208 765149661 414029641 732623232 712255040 159039212 714691832 342305611 484003601 851849639 263787652 777214270 794159439 41996071 8982860 868963277 167352505 298464932 886179731 139712335 373752306 969076728 750412958 336476037 918526734 649490954 582082684 6478...
result:
ok 100000 lines
Test #16:
score: 4
Accepted
time: 298ms
memory: 45640kb
input:
99993 6 100000 60046 73510 76743 90353 27819 41261 41945 55410 47263 60852 81275 94950 60884 74362 8070 21589 26792 40260 73860 87502 66467 80049 55282 68842 47250 60838 67914 81497 79147 92797 35992 49417 46246 59796 46324 59884 44798 58306 27714 41158 19818 33333 24670 38145 1298 14867 21186 34690...
output:
893388017 754362680 249579599 12536631 493430829 997196082 954778356 193378369 545282718 209938617 149828636 850176906 53339402 113376328 481989789 875311710 389604867 702078574 127109022 212626430 63899224 723846994 201197924 394280384 436023627 909840314 976693712 930361316 265814856 505217498 337...
result:
ok 100000 lines
Test #17:
score: 4
Accepted
time: 325ms
memory: 45660kb
input:
99992 7 100000 46709 62298 43845 59423 57608 73174 8380 23971 19686 35150 29121 44618 1189 16899 77233 92964 54510 70048 1366 17075 63662 79263 41721 57285 78703 94414 16275 31839 71866 87509 45626 61226 25380 40827 63233 78854 24302 39727 72140 87796 75448 91154 66375 81966 44357 59954 58893 74503 ...
output:
164257914 870698760 483542559 254154997 714714797 233002859 74528618 885485420 811731270 286933928 361895793 742966102 676455706 131788871 582981114 595797184 325503065 756154948 449993231 892666700 37974300 9891264 224331083 817020424 126548116 504918934 816264240 651790141 378570217 280439190 3271...
result:
ok 100000 lines
Test #18:
score: 4
Accepted
time: 363ms
memory: 45736kb
input:
99994 8 100000 65934 76851 57966 68909 52727 63644 9222 20158 75411 86373 28837 39739 88037 98979 52361 63310 14371 25383 49419 60352 9448 20401 87487 98458 23620 34585 7173 18125 60612 71502 74819 85797 55595 66567 4278 15237 8169 19086 88396 99329 31853 42703 44761 55565 80386 91426 55576 66544 37...
output:
674884528 442508336 69031518 596985079 755930125 572640590 885032909 322580118 879858856 245692252 360823228 965944266 635717924 360685071 754867730 205515090 431033349 70371766 674238163 454483607 436209819 934812348 884618736 713720511 518699701 954688580 337553932 449155412 989134051 358485665 46...
result:
ok 100000 lines
Test #19:
score: 4
Accepted
time: 362ms
memory: 45624kb
input:
99993 8 100000 27852 43018 65883 81212 55196 70592 66316 81648 60797 76161 10804 26079 3544 18697 61916 77265 49713 65101 80135 95471 8532 23772 23610 38740 79696 95032 18137 33318 70569 85974 44133 59536 16455 31626 40549 55877 53460 68867 9924 25192 17320 32454 63023 78373 68019 83342 23888 39026 ...
output:
705277784 527681475 963274060 409359498 346365044 424906723 272090538 159502875 894376422 851299906 921582884 777649969 142868118 181859130 194467396 248310379 483541577 824335659 314635244 134606728 617613678 244159815 120084653 486769738 573035498 930385822 898704021 987621577 730566348 643572592 ...
result:
ok 100000 lines
Test #20:
score: 4
Accepted
time: 349ms
memory: 45536kb
input:
99993 8 100000 4756 24312 12546 32006 56275 75922 30611 50207 58142 77797 11390 30842 69103 88760 20148 39670 61197 80850 2128 21632 45720 65404 4425 23981 34976 54654 44329 63987 23725 43324 79298 98996 21104 40646 24114 43700 35228 54890 63635 83351 12264 31726 62034 81706 42628 62284 15486 35013 ...
output:
855873060 997870547 686920469 86038596 243070412 167358956 791729660 778518285 18067867 473123423 203546383 542327137 449734685 559459914 364594469 832614051 594837051 183353085 93071321 808503202 434203677 3716710 520534783 560048174 380397352 86554046 909096731 576429228 138091973 700151231 564106...
result:
ok 100000 lines
Test #21:
score: 4
Accepted
time: 376ms
memory: 46232kb
input:
99997 6 100000 52795 76204 60242 94846 80082 89521 43789 83470 7347 17593 56216 67092 15233 91115 43430 52679 8086 21418 60025 82527 86078 94448 4145 27768 22185 40688 84161 88178 10627 48034 56113 60342 6327 66377 59696 81615 12544 43539 48748 75319 17899 80605 62730 88402 6995 14597 9331 23660 143...
output:
341223509 281976760 799841517 89929864 759191194 152870395 545793958 740838364 744626621 844022842 633442994 175586372 180444570 736173299 999676577 74273644 290518636 414077373 262619928 508267269 774824944 637002673 35643366 976053338 474412077 778021454 627215426 331193733 607234657 724698166 146...
result:
ok 100000 lines
Test #22:
score: 4
Accepted
time: 409ms
memory: 46228kb
input:
99992 7 100000 27128 54642 18776 48660 32020 81911 14635 52281 16313 49793 275 70381 3805 42531 32208 71097 22894 99371 4608 26589 2806 44204 47466 63243 48834 54881 27929 63878 27969 76632 20642 27385 14924 70165 16798 69834 29534 62692 76109 86503 37454 59613 6607 86600 1486 45880 7851 48183 3446 ...
output:
765452205 109089369 453262268 757472821 471932032 526784505 162942727 974141564 297409426 523713127 162214183 121289815 301011719 361855123 199169859 715426994 36772383 33014177 813744295 366215061 935545792 181041984 817902542 140463084 970866115 852872052 112827423 876602843 479295789 279087626 58...
result:
ok 100000 lines
Test #23:
score: 4
Accepted
time: 435ms
memory: 46224kb
input:
100000 8 99992 5525 88336 10461 93311 51747 91464 79890 89815 7705 13107 52076 64416 67400 81448 9571 24878 98891 99644 25122 79242 43829 70517 38851 76280 60902 72914 24253 41795 65752 75779 14486 83346 50461 60069 60825 83759 56425 84253 14562 41434 28226 77220 11636 84979 43610 72498 23200 61206 ...
output:
714876740 886356595 465434901 869323679 889785196 652086040 128373853 245348881 376326135 338867044 552468335 983724754 736822210 38782778 599022540 214885615 965843493 553490013 23968235 167981544 862930952 161888935 50288306 381460642 748230802 921126547 740527470 421245199 472577473 586196363 661...
result:
ok 99992 lines
Test #24:
score: 4
Accepted
time: 644ms
memory: 46224kb
input:
99996 13 100000 60077 60586 53452 64015 46838 89521 41235 50247 61110 70098 33221 77330 30075 79794 66972 79753 23114 76719 90895 93753 1570 12671 3476 16878 24750 97834 20280 68598 38680 53438 36049 48880 33061 56218 24232 79949 32570 75213 74546 95579 17573 96857 73405 85369 11909 16394 15237 5298...
output:
741716899 605068768 956076316 779231346 604967118 956553395 71409838 945191453 451780407 477715448 325152335 790266026 449479483 216348045 469924919 65250047 141841817 313715007 535821680 530325185 819822034 793966995 488746760 835728823 931394624 672939531 996316816 743257100 939625436 626387153 49...
result:
ok 100000 lines
Test #25:
score: 4
Accepted
time: 724ms
memory: 46192kb
input:
100000 14 99991 11683 30464 36116 93179 11630 72529 67922 83994 88958 94896 38498 53213 68662 87187 19199 42279 40847 61376 52053 76046 72860 80526 7846 28669 76791 81298 43954 61353 48538 86251 24262 90689 8142 52015 32987 68879 48867 59608 9690 40919 52857 74611 74249 80744 24417 81484 33024 48134...
output:
476842798 200549966 819237838 409458984 46801327 169532029 901895239 645089572 581001308 370989998 731472977 863778361 188141145 312207240 123014169 494668815 876234334 601662670 40930956 16847384 224396139 580716253 337385052 248847967 233201419 91982554 16985848 48056427 361520426 317345895 994829...
result:
ok 99991 lines