QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#872325#8804. Treasure Huntarnur2937#5 632ms132740kbC++233.6kb2025-01-26 00:47:322025-01-26 00:47:34

Judging History

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

  • [2025-01-26 00:47:34]
  • 评测
  • 测评结果:5
  • 用时:632ms
  • 内存:132740kb
  • [2025-01-26 00:47:32]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define static_assert(...);
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bigInt __int128
#define int long long
#define dl double long
#define fl float
#define all(s) s.begin(), s.end()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pob_front
#define ins insert
#define F first
#define S second
#define len length
const int N = 100005;
const int M = 1005;
const int LN = 131072;
const int MOD = 1e9 + 7;//998244353;
const int BLOCK = 500;
int binpow(int a, int b) {//, int MOD) {
    int res = 1;
    a %= MOD;
    while (b > 0) {
        if (b & 1) {
            res = res * a;
            res %= MOD;
        }
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}
// int MMI(int a, int MOD) {
//     int ret = binpow(a, MOD - 2, MOD);
//     return ret;
// }
// int mdiv(int a, int b) {
//     int ret = a*MMI(b);
//     ret %= MOD;
//     return ret;
// }
int mmul(int a, int b) {
    int ret = (a % MOD) * (b % MOD);
    ret %= MOD;
    return ret;
}
int madd(int a, int b) {
    int ret = (a % MOD) + (b % MOD);
    ret %= MOD;
    return ret;
}
int msub(int a, int b) {
    int ret = (a % MOD) - (b % MOD);
    ret = (ret + MOD) % MOD;
    return ret;
}
int GCD(int a, int b) {
    if (b == 0) {
        return a;
    }
    return GCD(b, a % b);
}
int LCM(int a, int b) {
    return a*b / GCD(a, b);
}
struct pqComp
{
    bool operator()(const pair<int, int>& p1, const pair<int, int>& p2) const
    {
        return (p1.F < p2.F) || (p1.F == p2.F && p1.S < p2.S);
    }
};
bool pCompF(pair<int, int>& p1, pair<int, int>& p2)
{
    return p1.F < p2.F;
}
bool pCompS(const pair<int, int>& p1, const pair<int, int>& p2)
{
    return p1.S < p2.S;
}
bool pCompFS(pair<int, int>& p1, pair<int, int>& p2)
{
    return (p1.S < p2.S) || (p1.S == p2.S && p1.F < p2.F);
}
vector <array<int, 3>> DS {{0, -1, 0}, {1, 0, 0}, {0, 1, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}};//, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
int n, m, a[10*N], vis[10*N], mx[10*N];
vector<pair<int,int>> g[10*N];
vector<int> vs;

void dfs(int v, int p = 0) {
    vis[v] = 1;
    vs.pub(v);
    for (auto u: g[v]) {
        if (vis[u.F] || u.S) continue;
        dfs(u.F, v);
    }
}

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        int v, u, w; cin >> v >> u >> w;
        g[v].pub({u, w});
        g[u].pub({v, w});
    }
    vector<int> ans(n + 1);
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs(i);
            int mx = 0;
            for (int v: vs) {
                mx = max(mx, a[v]);
            }
            for (int v: vs) {
                ans[v] = mx;
            }
            vs.clear();
        }
        cout << ans[i] << '\n';
    }
}

signed main() {
    speed;
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
}
/*
НЕ ЗАХОДИТ РЕШЕНИЕ?
1) ПРОВЕРЬ НА ОЧЕВИДНЫЕ ОШИБКИ В КОДЕ
2) ПРОВЕРЬ НА ПЕРЕПОЛНЕНИЯ
3) УБЕДИСЬ В ПРАВИЛЬНОСТИ АЛГОРИТМА
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 6116kb

input:

3000 3000
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 884526087 620...

output:

735362183
321648408
84435611
638030501
876390252
836223236
65247387
527734646
80970666
766403495
110657364
283475781
693285991
945447633
641155308
132890294
969038868
372617561
823982498
896717651
845481436
111374342
404588333
709818617
665021093
770870148
892408756
925221803
884526087
620849020
413...

result:

wrong answer 2nd lines differ - expected: '713607491', found: '321648408'

Subtask #2:

score: 5
Accepted

Test #14:

score: 5
Accepted
time: 575ms
memory: 111392kb

input:

1000000 1000000
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 8845260...

output:

999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999133
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
999999337
...

result:

ok 1000000 lines

Test #15:

score: 5
Accepted
time: 538ms
memory: 110016kb

input:

1000000 1000000
972166434 659979142 344453258 395615030 984580008 713698299 329234177 681387709 35749436 498013633 220323044 838758786 923230288 22789609 51100137 72217062 885300626 948320992 132324930 312694252 176178575 402178209 741891771 522780632 408427186 105944768 787335363 218283387 84937299...

output:

999997942
999997942
999995686
999997942
999992603
999991479
999991479
999988091
999969268
999997942
999997942
999873914
999873914
999997942
999992603
999998618
999997942
999998618
999949443
999992603
999992603
999997942
999990149
999992603
999998618
999997942
999998618
999992603
997438334
999995686
...

result:

ok 1000000 lines

Test #16:

score: 5
Accepted
time: 580ms
memory: 111548kb

input:

1000000 1000000
89876544 891255474 713979450 673065048 959236666 891228417 823405883 753035428 482478944 549110878 713746013 765809948 625394351 540810211 138742853 783651116 702745446 409263449 264555022 816159076 52123129 217641066 839925219 574406717 62302724 439732057 489026494 910128266 4432579...

output:

997108218
999999932
999999932
999963490
999999932
999999932
999999932
999992441
999999932
999999932
999999932
999999932
999999932
999999932
999963490
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
999999932
...

result:

ok 1000000 lines

Test #17:

score: 5
Accepted
time: 519ms
memory: 114232kb

input:

1000000 1000000
793525224 909688747 750789037 511849752 431764007 885119246 464824109 742677803 199820823 34793356 991685 318127360 799778183 278171072 862614259 267192454 642711694 428317910 810607357 480741050 514784297 820570476 698688676 191823894 921615000 435795527 702514858 632160218 62471189...

output:

999996535
999996535
999996535
999996535
999883720
999970342
999996535
999996535
999996535
999996535
999993870
999996535
999996535
999996535
999970342
999887305
999996535
999883720
999951943
999887305
999996535
999996535
999993870
999996535
999951943
999996535
999996535
999996535
999996535
999996535
...

result:

ok 1000000 lines

Test #18:

score: 5
Accepted
time: 556ms
memory: 130756kb

input:

900000 1000000
321300751 140965078 415282520 789299771 37824446 694053144 327592034 814325522 646550331 790923311 199447361 245178522 501942247 164787893 908787778 610030288 91560294 889260368 942837448 689238582 390728851 931000625 165318343 907013491 870457830 64550108 404205989 324005097 88216040...

output:

999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
999999023
...

result:

ok 900000 lines

Test #19:

score: 5
Accepted
time: 632ms
memory: 126672kb

input:

900000 1000000
853072294 184328520 380332875 620513228 851046910 645157134 222982604 599382365 896296393 522533449 309113041 800461527 395450055 168500942 23765315 844324348 376418272 169996506 251179881 400182475 426458699 926837200 502621781 425008213 318896631 104657437 594099887 617066681 847007...

output:

999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
999999090
...

result:

ok 900000 lines

Test #20:

score: 5
Accepted
time: 572ms
memory: 132740kb

input:

800000 1000000
675815113 47008633 749859066 529367026 457107349 412621836 380717820 671030084 48058608 278663402 507568717 727512688 392581410 55117763 774971543 555758401 825266873 630938964 678377265 608680007 302403253 373703837 600655228 140197809 972772170 438444726 295791018 235282631 73585959...

output:

999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
999998506
...

result:

ok 800000 lines

Test #21:

score: 5
Accepted
time: 584ms
memory: 128752kb

input:

800000 1000000
379463792 434038125 450232165 663119022 929634691 447981861 727168756 29268678 101836976 59313172 163410609 911233882 271997950 792478625 498842948 39299739 765233121 649993425 224429598 273261981 60031711 640196758 459418686 462647695 127051736 729475488 214312090 325910804 917313496...

output:

999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
999999993
...

result:

ok 800000 lines

Test #22:

score: 5
Accepted
time: 604ms
memory: 131596kb

input:

700000 1000000
907239320 296718238 746129428 645601748 535695129 920479272 516307753 100916397 548566484 110410418 656833578 206881262 269129306 679095446 176420246 750733793 582677942 110935882 356659690 850355733 641008975 792096104 926048354 809241072 780927275 63262777 916003222 649159463 879794...

output:

999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
999999484
...

result:

ok 700000 lines

Test #23:

score: 5
Accepted
time: 628ms
memory: 125776kb

input:

700000 1000000
439010862 3645191 79776002 771782497 348917593 166550553 411698322 885973241 798312546 547053265 61466548 467196975 867669823 387841203 996430494 321464341 203972407 686639313 370034831 192703406 971706114 377867262 968384499 327235794 524333368 398337398 105897120 942221048 771012693...

output:

999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
999999895
...

result:

ok 700000 lines

Test #24:

score: 5
Accepted
time: 598ms
memory: 125516kb

input:

600000 1000000
261753681 571358012 80705973 49232514 323574252 344080671 569433539 252588251 950074762 303183218 964954934 689215428 569833886 274458024 42604012 327865686 947788301 147581770 502264923 769797158 184087157 824733900 66417946 42425390 473176198 732124687 512620959 634065926 733493913 ...

output:

999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
999998388
...

result:

ok 600000 lines

Test #25:

score: 5
Accepted
time: 599ms
memory: 121764kb

input:

600000 1000000
670435069 958387505 486111781 519420999 91068885 379440697 620917183 610826846 593787714 378800280 547167898 872936622 375621498 11818885 766475417 516439732 592787256 830199743 48317257 434379132 310311835 796259529 925181405 364875276 963892254 23155448 652480396 356097878 914947811...

output:

999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
999998670
...

result:

ok 600000 lines

Test #26:

score: 5
Accepted
time: 565ms
memory: 113308kb

input:

500000 1000000
788145180 821067617 150605263 501903726 697129324 146905398 705023471 682474565 745549929 839962943 745623574 799987784 446381782 898435707 149085424 522841077 705199369 627578689 401885713 937843956 891289099 243126166 391811071 80064872 617767792 356942738 59204234 47942756 80380010...

output:

999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
999999780
...

result:

ok 500000 lines

Test #27:

score: 5
Accepted
time: 542ms
memory: 110672kb

input:

500000 1000000
24949430 159398350 115655618 628084475 510351788 98009389 674042969 467531408 995295992 571573080 855289254 428899715 971293370 902148756 632659182 462167845 31526542 908314829 488889782 58853265 221986237 533930033 24081800 229463376 729770105 397050067 322727061 341004341 768647008 ...

output:

999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
999997869
...

result:

ok 500000 lines

Test #28:

score: 5
Accepted
time: 291ms
memory: 69348kb

input:

100000 1000000
142659541 390674683 116585590 610567201 821444935 201910579 463181966 244211835 147058206 327703034 348712222 355950877 378490142 788765577 310236481 805005679 143938655 369257285 916087166 857285381 434367281 980796672 122115248 944652972 383645643 394400867 319385484 959220292 26095...

output:

999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
999968007
...

result:

ok 100000 lines

Test #29:

score: 5
Accepted
time: 331ms
memory: 71468kb

input:

100000 1000000
568865091 730166999 612860152 640405281 246687348 121584827 742583880 383352352 67645743 280790497 819849264 804580951 470839076 960131405 40757565 627994394 251442922 730005753 626398020 117380443 631979898 376693109 190005917 90751404 852962119 820137868 512124913 80468896 488830881...

output:

999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
999986582
...

result:

ok 100000 lines

Subtask #3:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 536ms
memory: 103608kb

input:

1000000 999999
735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 88452608...

output:

735362183
321648408
84435611
638030501
876390252
836223236
65247387
527734646
80970666
766403495
110657364
283475781
693285991
945447633
641155308
132890294
969038868
372617561
823982498
896717651
845481436
111374342
404588333
709818617
665021093
770870148
892408756
925221803
884526087
620849020
413...

result:

wrong answer 1st lines differ - expected: '979609066', found: '735362183'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%