QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605449#8038. Hammer to FallyangrunAC ✓313ms76676kbC++142.1kb2024-10-02 17:17:062024-10-02 17:17:06

Judging History

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

  • [2024-10-02 17:17:06]
  • 评测
  • 测评结果:AC
  • 用时:313ms
  • 内存:76676kb
  • [2024-10-02 17:17:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define mod 998244353
int qread() {
  int res = 0, flg = 1;
  char c = getchar();
  while(!isdigit(c)) {
    if(c == '-') flg = 0;
    c = getchar();
  }
  while(isdigit(c)) {
    res = (res << 3) + (res << 1) + (c ^ 48);
    c = getchar();
  }
  return flg ? res : -res;
}
const int N = 1e5 + 10;
int du[N];
struct cmp{
  bool operator()(pii a, pii b) {
    return a.se > b.se;
  }
};
vector<pii> vec[N];
priority_queue<pii, vector<pii>, cmp> prq[N];
map<int, int> ma[N];
int n, m, q, lim;
int a[N];
int ord[N], waste[N];
void update(int u) {
  int to, w;
  for(int i = 0; i < vec[u].size(); ++i) {
    to = vec[u][i].fi, w = vec[u][i].se;
    if(du[to] < lim) break;
    prq[to].push({u, w + waste[u]});
    ma[to][u] = w + waste[u];
  }
}
pii find(int u) {
  if(du[u] < lim) {
    int to, w;
    int rt, rw = 0x3f3f3f3f3f3f3f3f;
    for(int i = 0; i < vec[u].size(); ++i) {
      to = vec[u][i].fi, w = vec[u][i].se;
      if(w + waste[to] < rw) {
        rt = to, rw = w + waste[to];
      }
    }
    return {rt, rw};
  }
  while(ma[u][prq[u].top().fi] != prq[u].top().se) {
    prq[u].pop();
  }
  return prq[u].top();
}

signed main() {
  n = qread(), m = qread(), q = qread();
  lim = 1000;
  //lim = 0;
  int u, v, w;
  for(int i = 1; i <= n; i++) a[i] = qread();
  for(int i = 1; i <= m; i++) {
    u = qread(), v = qread(), w = qread();
    du[u]++; du[v]++;
    vec[u].push_back({v, w});
    vec[v].push_back({u, w});
  }
  for(int i = 1; i <= n; i++) {
    sort(vec[i].begin(), vec[i].end(), [](pii a, pii b)->bool{
      return du[a.fi] > du[b.fi];
    });
    update(i); 
  }
  for(int i = 1; i <= q; ++i) ord[i] = qread();
  
  pii nxt;
  for(int i = q; i; --i) {
    nxt = find(ord[i]);
    waste[ord[i]] = nxt.se;
    update(ord[i]);
  }
  
  int res = 0;
  for(int i = 1; i <= n; i++) {
    res = (res + a[i] % mod * waste[i] % mod) % mod;
  }
  cout << res << '\n';
  return 0;
}
/*
3 2 2
1 1 1
2 3 10
1 2 1
3 2
*/

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

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 14836kb

input:

3 2 2
1 1 1
2 3 10
1 2 1
3 2

output:

12

result:

ok single line: '12'

Test #2:

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

input:

2 1 10
5000 5000
1 2 10000
1 2 2 1 2 2 1 1 1 2

output:

550000000

result:

ok single line: '550000000'

Test #3:

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

input:

10 10 10
5 14 99 14 18 4 58 39 48 60
2 4 4
6 9 56
10 8 34
7 5 96
1 3 26
3 7 92
6 8 4
5 1 72
7 6 39
7 2 93
8 8 9 10 2 2 5 9 2 3

output:

8810

result:

ok single line: '8810'

Test #4:

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

input:

100 500 10000
89 61 65 85 89 2 32 97 13 70 29 86 68 74 84 64 54 39 26 84 56 95 73 11 70 26 60 40 84 58 68 33 65 71 55 2 11 71 49 85 14 59 38 11 60 8 81 78 27 32 52 49 35 94 62 72 64 50 12 45 77 74 92 67 92 38 81 39 12 29 60 70 53 33 25 60 7 83 4 85 47 32 13 58 85 86 44 68 44 1 81 62 97 7 66 62 5 16 ...

output:

609241

result:

ok single line: '609241'

Test #5:

score: 0
Accepted
time: 37ms
memory: 22876kb

input:

100000 100000 100000
134299012 740620432 241626312 533601686 901212368 274154852 46613593 72208460 685661661 930069933 934386896 140544225 900179749 8735320 54649110 922673925 450551589 517879800 773426781 410723403 783459037 344315202 75310230 122339501 113898579 646500753 18238713 119326471 969272...

output:

641103242

result:

ok single line: '641103242'

Test #6:

score: 0
Accepted
time: 58ms
memory: 18204kb

input:

448 100000 100000
411038009 847809848 901622409 143987890 230747977 330204397 58948994 635255827 124637955 446506876 693363517 282765360 687916399 598850473 404480258 958197468 332242997 7338874 321860348 37384562 440321061 434694843 935461053 803393359 852456369 428568442 233194935 663299156 907095...

output:

571525504

result:

ok single line: '571525504'

Test #7:

score: 0
Accepted
time: 44ms
memory: 19972kb

input:

800 100000 100000
251326676 820687742 668136087 685815400 271616099 930730049 622254842 263896849 496882119 842365233 827598659 952040530 71490970 870970052 583387021 380241141 573355930 302234935 73043289 694595013 308355368 412222215 132076042 970688532 157167052 932138361 941436777 33081400 29786...

output:

127243876

result:

ok single line: '127243876'

Test #8:

score: 0
Accepted
time: 32ms
memory: 21248kb

input:

2500 100000 100000
906300804 27973131 291731361 13136711 330409907 278210346 97382525 517930303 140685227 76822227 543248915 363117785 379028542 906572814 130403111 29847389 693506370 592704644 989452223 269178614 114603023 108858627 613364646 303414069 537766403 972627965 512287469 938256271 272592...

output:

922000064

result:

ok single line: '922000064'

Test #9:

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

input:

10000 100000 100000
168611457 237345210 879803481 965771982 336411698 283779723 795910140 511076651 625031271 962687567 982088706 658338866 214250373 76724769 976426858 178997802 124508865 478813203 990810948 918523277 15520937 320075177 818778935 449094027 979791260 335062620 345893885 601632901 55...

output:

984915144

result:

ok single line: '984915144'

Test #10:

score: 0
Accepted
time: 15ms
memory: 15580kb

input:

100 4950 100000
390 243 931 295 750 711 295 425 192 904 175 450 715 602 708 456 905 791 996 606 401 330 168 218 55 635 989 349 571 502 243 6 566 435 913 759 432 375 535 382 973 234 978 861 931 224 131 435 853 184 649 897 259 200 218 406 48 710 38 132 579 896 388 800 926 558 59 365 682 475 867 898 51...

output:

49445093

result:

ok single line: '49445093'

Test #11:

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

input:

10 5 1000
15 4 4 5 16 2 11 11 2 10
1 3 10
6 4 18
8 9 18
7 2 18
10 5 20
1 4 2 3 7 7 7 8 9 10 8 1 7 2 6 7 3 6 7 8 3 10 10 2 6 6 1 9 9 3 8 1 8 6 5 8 7 3 3 4 7 6 7 1 8 5 2 3 5 5 7 4 6 3 2 5 9 4 5 1 2 9 4 5 5 2 6 4 5 3 5 4 10 1 10 3 1 1 8 5 2 4 2 5 6 7 6 4 1 9 9 2 4 3 4 10 6 3 4 1 1 3 2 2 8 6 2 8 1 10 6 ...

output:

131690

result:

ok single line: '131690'

Test #12:

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

input:

7 14 10
291114498 673454859 532789761 628672010 833068294 412154083 525136251
3 5 92
4 1 57
7 3 90
2 3 96
6 7 81
6 3 100
6 1 71
2 4 76
2 1 97
6 4 73
2 7 97
6 5 87
2 5 100
6 2 5
6 2 2 6 6 2 2 2 2 6

output:

813329136

result:

ok single line: '813329136'

Test #13:

score: 0
Accepted
time: 57ms
memory: 26656kb

input:

40100 100000 100000
449328284 205410501 451233745 662762857 523774778 505289571 175281968 29821532 289051457 816202892 747849082 152467876 27551719 333462510 816680538 34877361 338141803 468189401 791444416 449513175 687791246 759960262 997873759 330313678 319983381 63035341 177327150 337347635 9634...

output:

901232016

result:

ok single line: '901232016'

Test #14:

score: 0
Accepted
time: 38ms
memory: 24960kb

input:

100000 100000 100000
573792977 201480175 45235867 914202012 246841206 701877700 703821119 37152009 575319618 930506992 703290810 881010700 63914136 96962139 933233795 280963567 671736608 908116432 365397906 284762912 171633220 5053568 330355941 56753074 824456884 854049151 181984509 289214427 855131...

output:

301752872

result:

ok single line: '301752872'

Test #15:

score: 0
Accepted
time: 178ms
memory: 27112kb

input:

11000 100000 100000
931900168 882945140 910307957 767815108 893736008 472640378 323257118 532573916 46252670 658707412 661885079 218681792 377604907 557835654 687412683 603599082 965397828 175104803 474273369 895294122 974715313 776504917 482395923 709979556 668182992 956178523 278742143 170793808 6...

output:

450462060

result:

ok single line: '450462060'

Test #16:

score: 0
Accepted
time: 98ms
memory: 27256kb

input:

21000 100000 100000
423267538 371203658 214114102 60328794 842100474 273553151 351444639 123443269 603555206 821378648 917426170 355158052 259201908 873963579 509329177 355474684 104537734 462995696 998746832 478755191 426722246 155307427 243458936 720160611 835264509 245911268 160206703 134083123 9...

output:

537725466

result:

ok single line: '537725466'

Test #17:

score: 0
Accepted
time: 60ms
memory: 25696kb

input:

31000 100000 100000
342252174 878226238 589362395 675155220 522398294 344269130 839340346 507244641 684566644 461671648 482815896 467836007 553844248 162408963 294342066 118276034 293534762 239795082 523928633 198513446 677832645 166890401 881058129 578123735 719662774 678873672 171753747 890830895 ...

output:

485570800

result:

ok single line: '485570800'

Test #18:

score: 0
Accepted
time: 54ms
memory: 28924kb

input:

50000 100000 100000
757088818 73185044 602483416 732346792 997675995 338699262 612527879 725332311 280390519 51769782 671098898 241336332 800948824 412010644 482376542 45192576 404890903 547025877 719095252 576254098 477907469 6774296 245538913 827814853 393359835 596647905 30596726 443093949 422114...

output:

106145504

result:

ok single line: '106145504'

Test #19:

score: 0
Accepted
time: 101ms
memory: 29040kb

input:

50000 100000 100000
419250629 150632961 590763842 31818542 311298205 632739311 759591628 200255897 795498028 418868357 693412755 816679244 514043045 992435505 506090854 937492446 172410129 871311955 563404839 943230235 888709578 99368896 106340939 952044928 268690176 839181120 787037019 141712064 22...

output:

910071343

result:

ok single line: '910071343'

Test #20:

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

input:

40100 100000 100000
30010083 227668969 241095349 830895822 97787900 322581344 496084693 750727326 947604134 782156260 282635671 55195519 867231040 981755524 301932707 714940893 921380188 77329572 86172183 900244915 943760961 998273659 787033345 631259925 162116969 510736278 827863016 184110246 67147...

output:

925392146

result:

ok single line: '925392146'

Test #21:

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

input:

52094 94021 95019
816959499 20123178 406126632 61956254 41417583 577485833 667512043 872266782 365199489 440825887 871669736 743504767 168921593 22436552 671983144 260334270 347307602 804634052 77460664 948542335 721266251 575343289 648919849 579171719 581603175 222021036 315184656 52733760 59438910...

output:

4333605

result:

ok single line: '4333605'

Test #22:

score: 0
Accepted
time: 161ms
memory: 33676kb

input:

16000 100000 100000
675966004 620856303 51951252 330409698 803113424 630293316 675360544 906272711 51557968 212239870 156015027 30612856 914144087 976127505 657829242 120790916 175308859 457241155 896105620 408037770 277581959 659510961 60974231 4372929 625221753 654880074 928380171 895489395 182142...

output:

73682281

result:

ok single line: '73682281'

Test #23:

score: 0
Accepted
time: 66ms
memory: 27076kb

input:

100000 100000 100000
594788838 36909266 886574764 108945456 654938493 456981675 89800636 746149630 917244962 467057036 395081389 673442668 931785689 215541448 686470413 522468455 759892056 715634823 825406300 950725359 726350218 38943813 107393423 122752156 598189069 133388113 449195918 413075991 61...

output:

606130408

result:

ok single line: '606130408'

Test #24:

score: 0
Accepted
time: 128ms
memory: 28484kb

input:

43210 100000 100000
62766712 781369596 185824176 344820051 664282109 531338101 194014059 281357138 56334567 328473016 41866515 282663760 420500569 688616654 282990658 58390628 647590920 968380023 420396137 49506708 889422526 600308645 892127051 706258015 466669783 576844542 768458111 327559476 52969...

output:

794582170

result:

ok single line: '794582170'

Test #25:

score: 0
Accepted
time: 37ms
memory: 19876kb

input:

1000 100000 100000
589023099 448281621 811738376 820544135 612790292 761048948 262607686 249992865 206763874 676400407 496295080 60259623 664350841 963280558 633942848 877493658 379700367 558107308 436946312 414557311 483806078 741498056 602668251 821323742 820592195 134681725 820048377 28884422 281...

output:

843900450

result:

ok single line: '843900450'

Test #26:

score: 0
Accepted
time: 32ms
memory: 20004kb

input:

1200 100000 100000
108416675 242617775 537667315 556448650 432611023 485189068 332784510 944261332 639672204 119299926 957885680 683891478 471150960 971898867 435005252 413131046 754413561 328964299 860172696 40327585 278840327 878081805 522324142 659363172 226005597 207726185 839099244 226028052 98...

output:

279369761

result:

ok single line: '279369761'

Test #27:

score: 0
Accepted
time: 54ms
memory: 18700kb

input:

447 99681 100000
253172909 404106891 516704004 395937554 948561151 960714787 801826087 141017390 773008020 907743263 342675415 514922722 125442073 241050921 59554947 28358764 764412384 470960177 22539905 709496973 963412577 583159530 633526152 212320009 424724659 373716554 50376756 664150315 5702244...

output:

630632624

result:

ok single line: '630632624'

Test #28:

score: 0
Accepted
time: 8ms
memory: 15920kb

input:

25 300 100000
813851460 152751244 176042866 213295578 341896768 295038668 235567252 138110625 896713082 861793074 375489371 172995908 72894061 61222429 38958189 925772889 194566028 320857085 785019558 274264524 868906169 106891225 46032788 579960669 241667022
1 2 100000
1 3 100000
1 4 100000
1 5 100...

output:

595513487

result:

ok single line: '595513487'

Test #29:

score: 0
Accepted
time: 71ms
memory: 29308kb

input:

50002 100000 100000
519308598 52649725 918883324 49384732 77295597 189912031 157476355 903032838 942085249 423301595 943042631 943971498 641289064 54783856 519634169 172455633 309063212 29622351 965658780 385498297 549703145 606532576 102526599 467309456 717886419 328135102 687293799 641636349 65877...

output:

415488147

result:

ok single line: '415488147'

Test #30:

score: 0
Accepted
time: 52ms
memory: 24900kb

input:

49361 98720 99956
737621911 1123172 39162458 288993151 693339077 23545620 408462140 709883227 569804464 193784617 646575079 52316416 744038376 384796915 232034240 871613956 842724499 108771664 26555769 534656728 574767441 85376578 992701834 206325421 196527592 358574908 581255102 59218574 871519294 ...

output:

575245270

result:

ok single line: '575245270'

Test #31:

score: 0
Accepted
time: 39ms
memory: 24696kb

input:

46141 92280 99972
869113912 125779440 688147243 226580395 160922184 349926667 570653865 358783624 371544233 389955223 301933675 474748106 866477712 290780277 636779980 996167124 687176763 44279375 425275211 493871 47206405 818058845 812732733 163122899 435464195 317566957 277429188 932877507 2624118...

output:

466496833

result:

ok single line: '466496833'

Test #32:

score: 0
Accepted
time: 313ms
memory: 76676kb

input:

1566 100000 100000
357136045 546248240 71714934 626093761 588848964 684848380 340255428 638918504 819583498 678185684 774094102 650906867 879422757 277901400 830135879 243580377 138900057 171049869 646868795 51556034 400433127 488238120 271586392 61486255 439732825 686997842 975407270 590930970 3050...

output:

364599719

result:

ok single line: '364599719'

Extra Test:

score: 0
Extra Test Passed