QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#817466 | #1420. Presents | modwwe | 100 ✓ | 30ms | 19036kb | C++23 | 3.5kb | 2024-12-16 23:24:55 | 2024-12-16 23:24:57 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while (c < '0' || c > '9')
{
c = getchar_unlocked();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + c - '0';
c = getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf = 2e18;
const ll mod2 = 998244353;
const int mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
if(x+y>=mod2) x-=mod2;
if(x+y<0)x+=mod2;
return x+y;
}
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a, b, c;
};
struct id
{
int a, b, c, d;
};
struct ie
{
int a, b, c, d, e;
};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,k1,k2,k3,s11,lim,w,l,r,ans ;
int kk;
int el = 19;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
//modwwe
phongbeo(),down
// checktime
}
int dp[100001][2][2];
bool g[100001];
int in[100001];
vector<int> topo;
int dp2[2][2];
int a[100001],b[100001],c[100001],d[100001];
bool cc[100001];
void dfs(int x)
{
in[x]=1;
if(in[a[x]]==1)
{
cc[a[x]]=1;
g[x]=1;
}
if(in[a[x]]==0)
dfs(a[x]);
topo.pb(x);
in[x]=2;
}
void phongbeo()
{
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i]>>b[i]>>c[i]>>d[i];
for(int i=1; i<=n; i++)
if(!in[i])
dfs(i);
reverse(topo.begin(),topo.end());
for(auto x:topo)
{
if(cc[x])dp[x][1][0]=dp[x][0][1]=-inf;
/// if(x==1) cout<<dp[x][1][1]<<" "<<dp[x][0][0],down
if(g[x])
{
s5=0;
for(int f=0; f<=1; f++)
for(int f2=0; f2<=1; f2++)
{
int cost;
int y=a[x];
if(f==f2) cost=b[x]*c[y];
else cost=b[x]*d[y];
s5=max(s5,dp[x][f][f2]+cost);
}
s4+=s5;
continue;
}
for(int f=0; f<=1; f++)
for(int f2=0; f2<=1; f2++)
for(int f3=0; f3<=1; f3++)
{
if(dp[x][f][f3]==-inf) continue;
int cost;
int y=a[x];
if(f==f2) cost=b[x]*c[y];
else cost=b[x]*d[y];
///if(x==5&&f3==1&&f2==1) cout<<b[x]<<" "<<y<<" "<<d[y]<<" "<<c[y],down
dp2[f2][f3]=max(dp2[f2][f3],cost+dp[x][f][f3]);
}
int y=a[x];
for(int f2=0; f2<=1; f2++)
for(int f3=0; f3<=1; f3++)
dp[y][f2][f3]+=dp2[f2][f3],dp2[f2][f3]=0;
}
cout<<s4;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 7744kb
input:
15 5 156124 759262 540659 3 376023 847098 496048 5 869684 224033 481616 15 758215 993124 884982 12 324453 529584 605059 14 637383 156355 366167 5 497394 719355 132683 11 778498 670894 188938 1 85137 679422 501310 2 729325 23543 987186 1 559944 291647 782679 9 55452 758286 30014 6 374455 845578 71160...
output:
4437104527091
result:
ok single line: '4437104527091'
Test #2:
score: 10
Accepted
time: 1ms
memory: 7760kb
input:
16 10 901205 222886 778135 9 629286 354262 677363 15 448442 6929 917938 12 203146 988311 657457 7 832652 82375 512911 2 997255 67463 545192 4 359994 531259 174337 13 506731 885103 796142 16 984052 961290 7280 8 756047 669483 818936 1 397156 231133 961819 14 332319 342175 146640 5 380745 57323 229526...
output:
6818494910997
result:
ok single line: '6818494910997'
Test #3:
score: 10
Accepted
time: 0ms
memory: 7768kb
input:
16 3 499161 648987 701859 12 250274 469882 4694 14 328893 113538 972364 8 380296 240746 308368 9 547671 93085 979169 11 902204 692943 755622 1 128455 276268 31858 2 569787 852402 311263 16 803793 206263 199325 4 900524 156199 239392 13 891927 607986 996722 7 508532 688001 966086 5 725688 183857 2141...
output:
4968095649842
result:
ok single line: '4968095649842'
Test #4:
score: 10
Accepted
time: 1ms
memory: 5656kb
input:
15 14 894793 587470 781563 9 118543 807284 480090 7 671637 889759 161327 3 865403 480746 967069 11 156785 55244 817205 2 114139 419190 789934 4 284345 660340 198589 2 863786 366861 935559 6 914279 857486 360202 1 352729 743147 824799 15 993876 281989 455656 6 758986 623316 567515 14 807833 684589 65...
output:
6074580429565
result:
ok single line: '6074580429565'
Test #5:
score: 10
Accepted
time: 1ms
memory: 5724kb
input:
16 5 277883 803430 385806 5 36963 942552 942552 5 711653 762890 382331 5 504574 805072 737879 2 21393 494323 60661 13 388363 709656 263220 12 525555 817546 879532 4 828189 342667 798154 13 317764 611866 652495 4 746442 305473 112740 5 618417 521684 10474 5 369932 490288 364662 11 625037 488978 99925...
output:
4376631726935
result:
ok single line: '4376631726935'
Test #6:
score: 10
Accepted
time: 1ms
memory: 7680kb
input:
16 3 815817 705683 326249 9 400225 516302 865977 9 538160 354289 265756 3 869181 233527 637254 10 466701 570250 313532 9 971428 8087 955858 13 797775 864350 102362 14 388814 904252 803957 6 723867 288514 189820 14 537536 169167 651022 10 137084 407373 973317 5 863095 68560 488878 9 662180 834947 366...
output:
4433614707903
result:
ok single line: '4433614707903'
Test #7:
score: 10
Accepted
time: 1ms
memory: 7688kb
input:
2 2 905889 152467 539971 1 73622 92674 14369
output:
95177282660
result:
ok single line: '95177282660'
Test #8:
score: 10
Accepted
time: 1ms
memory: 7688kb
input:
16 15 840354 995128 443120 6 366299 985607 560024 8 793514 369450 721083 10 409559 870715 200332 7 964690 761002 118880 2 364870 281530 417692 5 90337 327603 331734 3 734689 958772 653097 12 345071 767987 423547 4 435533 84685 213705 16 944938 796002 455294 9 190668 307713 875250 14 804012 166459 65...
output:
4715953750827
result:
ok single line: '4715953750827'
Subtask #2:
score: 33.3333
Accepted
Dependency #1:
100%
Accepted
Test #9:
score: 33.3333
Accepted
time: 2ms
memory: 8000kb
input:
5000 2839 52 25 63 3454 35 41 79 1102 72 34 10 4419 13 77 47 2977 91 60 34 3396 43 43 43 2114 86 4 82 1956 89 35 31 3974 47 80 95 4887 84 59 52 656 21 48 17 1942 58 40 17 3975 88 91 89 1498 43 17 5 1178 70 2 13 4737 94 87 85 4914 41 35 29 79 55 13 12 2218 91 79 8 4963 73 60 79 4402 70 43 32 4578 19 ...
output:
16874682
result:
ok single line: '16874682'
Test #10:
score: 33.3333
Accepted
time: 0ms
memory: 8312kb
input:
5000 4940 18 78 77 4798 1 90 65 4134 43 88 84 4353 8 3 34 1694 59 29 51 3421 32 46 52 4460 88 94 24 3041 20 45 38 233 52 97 35 1951 1 7 89 4751 92 92 18 2319 87 51 14 2434 70 10 20 2830 29 20 25 4023 35 79 52 1215 33 75 20 3139 43 92 50 3184 2 99 91 4058 79 84 16 1171 76 14 100 4762 59 19 13 2130 16...
output:
17149126
result:
ok single line: '17149126'
Test #11:
score: 33.3333
Accepted
time: 2ms
memory: 6436kb
input:
5000 1350 62 16 38 1310 68 47 62 3525 42 13 26 943 52 28 90 4593 48 29 72 1269 13 36 7 4458 78 50 22 4494 89 62 72 3964 77 69 65 2336 49 17 54 820 93 82 90 4759 1 97 76 2806 60 57 85 1639 13 59 94 2225 77 3 56 695 43 25 100 510 72 77 16 151 85 69 54 2860 6 76 53 2213 22 79 49 1693 39 77 94 4644 16 1...
output:
17004646
result:
ok single line: '17004646'
Test #12:
score: 33.3333
Accepted
time: 2ms
memory: 7984kb
input:
3333 2097 100 63 33 1170 2 47 24 534 72 40 93 2220 33 38 47 2931 100 44 10 470 48 75 48 2400 69 73 31 495 69 15 19 142 20 27 90 2810 53 5 100 993 66 41 13 2451 85 50 16 955 23 56 61 688 18 77 79 2193 58 78 52 2827 37 40 36 1426 27 22 88 2581 50 78 70 2103 25 55 32 3203 37 24 47 2158 12 45 5 1480 66 ...
output:
11259811
result:
ok single line: '11259811'
Test #13:
score: 33.3333
Accepted
time: 2ms
memory: 7948kb
input:
5000 4373 28 39 25 3379 83 59 72 4552 57 16 24 102 37 70 37 755 45 12 97 3758 20 7 20 2217 22 3 45 768 38 79 95 3815 40 15 63 1547 20 97 26 4117 25 21 14 4014 93 62 85 3789 42 97 91 2134 16 71 69 2007 25 79 75 217 95 6 14 1837 50 79 72 623 28 3 36 1458 72 94 3 1994 59 2 56 4409 56 5 29 2991 77 63 19...
output:
16762585
result:
ok single line: '16762585'
Test #14:
score: 33.3333
Accepted
time: 2ms
memory: 6424kb
input:
5000 1127 479048 216519 497995 2150 951282 379558 449452 1851 392655 314902 249171 2294 811321 583702 736310 2373 81191 4274 187234 2808 783584 179580 353278 642 431029 94428 298079 4191 497712 465861 892422 1539 905731 87874 182060 147 752586 918806 596464 1869 813697 169969 459940 728 56577 567857...
output:
1654619680760243
result:
ok single line: '1654619680760243'
Test #15:
score: 33.3333
Accepted
time: 3ms
memory: 8252kb
input:
5000 1009 560857 665533 230331 4250 925223 628836 204777 994 866034 62502 432497 1526 284935 700173 362196 86 78703 331962 621368 265 356856 878949 52663 1244 678909 715759 119985 3579 212190 536651 425886 1893 880528 56897 889294 3040 939901 314933 196893 1014 983082 80446 716257 663 649410 423709 ...
output:
1662890299920098
result:
ok single line: '1662890299920098'
Test #16:
score: 33.3333
Accepted
time: 2ms
memory: 6080kb
input:
4321 3146 652513 778725 197273 798 867031 1517 618821 4075 191914 692449 657506 2065 411697 191733 199804 2484 428267 113312 226374 1521 135938 971852 689020 1810 889274 973711 546583 3939 445353 955696 714112 1467 915505 470508 915415 3675 957274 417364 930823 2992 146789 706750 521206 3635 671294 ...
output:
1445179830615949
result:
ok single line: '1445179830615949'
Test #17:
score: 33.3333
Accepted
time: 2ms
memory: 6028kb
input:
5000 3470 795827 259361 105340 4263 930988 740835 660820 527 492896 648557 249162 173 275794 560898 776798 54 918334 554440 503437 1753 96322 439734 283718 374 207541 552890 90324 846 541506 761721 120903 1992 929130 540157 316671 1971 925873 523523 300852 1609 498790 507798 665410 1857 212223 33754...
output:
1688462627233308
result:
ok single line: '1688462627233308'
Test #18:
score: 33.3333
Accepted
time: 0ms
memory: 7864kb
input:
5000 1122 452276 227803 291099 1122 665749 37508 19400 1122 575010 84750 715931 1122 491888 713693 543880 1122 582732 718813 758943 1122 92757 918923 77524 1122 368464 30236 838472 1122 373266 737383 56231 1122 22618 781833 639248 1122 576317 94829 715908 1122 541461 750445 111241 1122 760774 326664...
output:
1800373222308612
result:
ok single line: '1800373222308612'
Test #19:
score: 33.3333
Accepted
time: 2ms
memory: 6396kb
input:
5000 1930 605832 953305 603093 3273 505264 698514 547995 1357 784819 119057 154893 4945 895338 947594 443668 96 686981 327477 703408 2633 606893 671999 494993 2720 224009 456155 617275 3326 408974 59837 241088 1284 808934 469759 387910 1697 18519 361601 832109 3466 969246 449260 922837 1495 48652 55...
output:
1641409814346806
result:
ok single line: '1641409814346806'
Test #20:
score: 33.3333
Accepted
time: 2ms
memory: 7984kb
input:
5000 1018 706701 547743 840117 4079 140759 938990 616515 575 631182 546596 806341 2972 66767 521081 963938 2627 242 144821 334996 3172 687150 840874 693828 3634 54623 690466 940220 4918 439253 876363 507393 1221 743370 327040 392203 3103 953138 661687 576392 3777 95664 89486 619219 421 445562 799333...
output:
1464303244449056
result:
ok single line: '1464303244449056'
Subtask #3:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #21:
score: 20
Accepted
time: 22ms
memory: 11196kb
input:
100000 67558 20 92 64 83240 91 8 50 10248 24 63 65 82525 77 79 61 7738 7 97 34 6528 68 47 20 18822 77 58 88 27738 12 84 73 83156 3 3 97 49784 54 77 79 67719 68 9 15 15136 98 80 3 6361 67 8 67 8900 76 86 79 35510 79 80 93 98396 50 35 45 1463 3 47 85 74410 10 87 79 76645 51 27 94 5453 20 36 40 94779 6...
output:
337504482
result:
ok single line: '337504482'
Test #22:
score: 20
Accepted
time: 26ms
memory: 19036kb
input:
100000 89706 18 59 89 23035 32 78 37 70677 62 33 65 18234 69 100 25 30400 4 24 15 40799 25 4 93 76750 92 51 24 33749 9 39 16 79224 1 44 95 60070 85 15 56 22360 27 28 2 78679 44 92 50 97390 63 13 12 27123 85 6 44 95036 1 74 27 53750 44 98 45 4092 99 90 31 36771 79 51 87 88777 63 76 68 89285 10 53 61 ...
output:
340055118
result:
ok single line: '340055118'
Test #23:
score: 20
Accepted
time: 30ms
memory: 18992kb
input:
100000 90664 40 68 2 39922 88 9 100 86022 14 76 50 98913 26 21 76 96093 92 84 19 81652 47 28 41 30843 46 10 67 96781 2 76 45 43134 71 52 78 27698 84 86 38 16419 49 22 80 70709 84 74 90 31070 93 27 29 64691 70 8 60 29247 84 46 25 52140 55 81 6 60032 79 89 94 9760 88 35 84 71050 23 57 82 32520 16 28 2...
output:
340572542
result:
ok single line: '340572542'
Test #24:
score: 20
Accepted
time: 18ms
memory: 13180kb
input:
77777 31710 39 55 73 8379 89 78 18 44533 22 66 57 30192 23 19 35 21057 65 2 19 6116 36 12 2 72916 98 95 92 7929 45 19 95 21361 87 27 49 62874 87 74 65 2315 32 69 73 50291 21 56 49 1324 88 70 58 71985 19 47 93 21644 32 44 43 23155 60 56 7 16528 62 31 88 67205 81 32 88 40740 60 91 54 28169 33 51 67 29...
output:
263962508
result:
ok single line: '263962508'
Test #25:
score: 20
Accepted
time: 24ms
memory: 11248kb
input:
100000 11045 90 7 99 79960 4 56 8 5426 5 23 7 39594 70 84 36 46396 78 50 11 91343 92 91 44 4320 21 89 94 35372 4 10 87 73491 13 61 86 46919 47 40 89 44765 78 77 22 28031 5 9 85 98535 5 6 12 59030 47 79 95 65762 55 94 77 55111 57 35 3 23826 33 60 81 6636 26 79 51 57601 36 69 13 20443 86 47 29 6013 33...
output:
340911171
result:
ok single line: '340911171'
Test #26:
score: 20
Accepted
time: 27ms
memory: 11240kb
input:
100000 13870 1000000 1000000 1000000 38732 1000000 1000000 1000000 96096 1000000 1000000 1000000 78196 1000000 1000000 1000000 44012 1000000 1000000 1000000 55191 1000000 1000000 1000000 64444 1000000 1000000 1000000 60715 1000000 1000000 1000000 86085 1000000 1000000 1000000 31860 1000000 1000000 1...
output:
100000000000000000
result:
ok single line: '100000000000000000'
Test #27:
score: 20
Accepted
time: 23ms
memory: 12472kb
input:
100000 523 296071 293670 47723 10439 93408 892375 856462 53129 594146 918711 284092 65153 708383 302091 555668 61829 785373 848758 678470 26551 916630 295446 503917 74327 610400 909244 122174 81224 355000 281139 663003 80883 478804 806397 924571 52752 975232 863934 832378 717 65286 779514 608593 717...
output:
33242269402049539
result:
ok single line: '33242269402049539'
Test #28:
score: 20
Accepted
time: 24ms
memory: 15256kb
input:
100000 23744 563167 451511 350465 68476 569194 890239 836332 14541 604926 324845 503280 7789 260428 523818 853434 43587 769773 708979 676043 99693 367593 959365 933699 32718 819268 313605 964040 4569 988106 357190 896030 64897 418376 453256 895664 17472 251578 757763 724517 97997 319185 814316 59733...
output:
33341939294983750
result:
ok single line: '33341939294983750'
Test #29:
score: 20
Accepted
time: 22ms
memory: 11268kb
input:
98765 45225 755387 474881 617990 57777 656610 383782 835607 83171 454540 903461 184587 75705 664422 681251 286101 69966 558454 194342 613913 78802 168882 329911 644159 73331 776200 231660 531961 98557 50007 190278 294314 54381 328973 981306 431641 85347 361632 606802 665340 68571 206414 603876 50201...
output:
32742364523544150
result:
ok single line: '32742364523544150'
Test #30:
score: 20
Accepted
time: 27ms
memory: 11264kb
input:
100000 30602 272065 168075 13773 33262 135056 435564 175104 95855 657738 281508 465734 28119 998618 738305 474047 18112 122870 330626 328744 35083 524213 19625 898013 20071 230057 724756 403119 11650 455394 663967 628047 2984 850457 322841 807394 73039 730272 304164 139021 29033 636336 142568 501292...
output:
33344112683991025
result:
ok single line: '33344112683991025'
Test #31:
score: 20
Accepted
time: 19ms
memory: 10096kb
input:
100000 10841 773332 259079 828408 10841 449460 454095 280715 10841 809057 610705 927765 10841 521172 914261 547938 10841 2114 369193 309864 10841 270484 598072 66832 10841 23976 478361 29880 10841 160588 501866 851575 10841 522271 174233 362802 10841 672482 864736 959747 10841 492490 558508 443220 1...
output:
15598294676204352
result:
ok single line: '15598294676204352'
Test #32:
score: 20
Accepted
time: 24ms
memory: 11200kb
input:
100000 97961 869739 133723 491234 82975 312375 500812 449915 82975 963114 453552 847454 81843 432896 959758 651408 82975 911473 404743 395654 59684 129525 155893 158615 98726 965438 160826 466927 82975 899343 955761 811287 54931 880481 249420 321136 74733 248972 763277 696039 82975 667459 351333 221...
output:
24057500706631185
result:
ok single line: '24057500706631185'
Test #33:
score: 20
Accepted
time: 20ms
memory: 11348kb
input:
100000 9524 91341 884560 638609 23271 877497 522397 303205 95714 129752 958656 228659 20423 724402 496479 339024 94743 497955 344287 416304 16803 315781 332717 743837 22956 867610 606369 687708 29234 970993 169508 536169 57259 415306 513775 653206 82830 448114 531845 5442 8990 770865 631432 272040 2...
output:
33282301809166375
result:
ok single line: '33282301809166375'
Test #34:
score: 20
Accepted
time: 26ms
memory: 11260kb
input:
100000 37464 492519 681780 389060 87986 75143 350779 413487 17737 576758 286688 777270 46560 594249 408392 629061 47334 30810 921217 51208 96792 44018 909503 205363 44564 13685 995679 955979 11823 590265 934385 139052 48184 318177 557006 840548 9952 321564 381220 376655 76942 615028 864343 588092 81...
output:
33197298910607417
result:
ok single line: '33197298910607417'
Test #35:
score: 20
Accepted
time: 26ms
memory: 14112kb
input:
100000 78593 528803 670873 766920 24266 132974 411776 95986 73897 466211 540483 416367 22216 781761 296355 637624 38947 936782 50366 869068 89917 707881 673278 368742 44972 64736 679730 370914 8119 572142 548909 508654 38612 746807 418884 320812 57913 46651 974796 211164 28682 164013 766932 188566 6...
output:
33428991120135274
result:
ok single line: '33428991120135274'
Test #36:
score: 20
Accepted
time: 27ms
memory: 12404kb
input:
100000 81264 804351 593050 833773 14601 968766 962473 140530 39074 592600 660735 743652 58204 53748 275564 70245 92966 846916 415929 75341 41168 490154 640709 964650 34280 211086 239884 640005 13857 29767 72901 222043 75360 75462 584175 186620 64568 618043 889920 273101 22796 148071 473074 448410 63...
output:
33225215679289238
result:
ok single line: '33225215679289238'
Test #37:
score: 20
Accepted
time: 21ms
memory: 11368kb
input:
100000 30824 451394 587636 228973 9287 393726 883766 253478 99726 94528 645219 759098 24222 74178 701667 192789 10454 627957 799582 805819 84687 471077 62571 473730 90596 815992 950683 827923 4384 176087 733908 388016 11606 450088 948584 4895 5295 796924 330023 803516 56840 754243 943203 140356 4583...
output:
29351117905257644
result:
ok single line: '29351117905257644'
Extra Test:
score: 0
Extra Test Passed