QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#872297#8804. Treasure Huntarnur2937#0 586ms103904kbC++233.3kb2025-01-26 00:38:192025-01-26 00:38:20

Judging History

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

  • [2025-01-26 00:38:20]
  • 评测
  • 测评结果:0
  • 用时:586ms
  • 内存:103904kb
  • [2025-01-26 00:38:19]
  • 提交

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];

void dfs(int v, int p = 0) {
    vis[v] = 1;
    mx[v] = max(mx[p], a[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});
    }
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs(i);
        }
        cout << mx[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: 5992kb

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: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 586ms
memory: 101416kb

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:

735362183
988279674
996103958
999676982
994486864
997167205
999249871
999249871
996103958
999249871
999249871
990870855
999249871
945447633
997688933
999429410
998888776
999249871
999249871
994486864
999249871
999549488
999249871
998888776
994486864
992635579
999249871
999249871
999249871
994486864
...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 533ms
memory: 103904kb

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%