Submission #574113

# Submission time Handle Problem Language Result Execution time Memory
574113 2022-06-07T21:46:20 Z hossain2020 Lost Array (NOI19_lostarray) C++14
100 / 100
43 ms 5288 KB
#include <bits/stdc++.h>

#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define ll long long
#define endl "\n"
#define S second
#define F first
#define ff cout.flush();
#define all(x) x.begin(),x.end()

using namespace std;
bool pri (int a)
{
    if (a<=1)return 0;
    for (int i=2;i*i<=a;i++)
    {
        if (a%i==0)
        {
            return 0;
        }
    }
    return 1;
}
ll mod=1000000007;
ll Fastpower(ll x, ll y){
    if (y == 0) return 1;
    if (y == 1) return x;
    ll ret = Fastpower(x, y / 2);
    ret = (ret * ret) % mod;
    if (y % 2 != 0) ret = (ret * x) % mod;
    return ret;
}
ll n,m,a,b,c,o[200000];
vector<pair<ll,pair<ll,ll> > > s;
signed main()
{
    fast;
    srand(time(NULL));
    cin>>n>>m;
    ll z=m;
    for (int i=0;i<=n;i++)o[i]=1;
    while (z--)
    {
        cin>>a>>b>>c;
        if (b<a)swap(a,b);
        s.push_back({a,{b,c}});
        o[a]=max(o[a],c);
        o[b]=max(o[b],c);
    }
    sort(all(s));
    for (int i=0;i<m;i++)
    {
        a=s[i].F;
        b=s[i].S.F;
        c=s[i].S.S;
        if (c==o[a])continue;
        else o[b]=c;
    }
    for (int i=1;i<=n;i++)
    {
        cout<<o[i]<<" ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 7 ms 1144 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 7 ms 1144 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 980 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1232 KB Output is correct
2 Correct 12 ms 1940 KB Output is correct
3 Correct 9 ms 1996 KB Output is correct
4 Correct 5 ms 1232 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 7 ms 1144 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 4 ms 980 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 8 ms 1232 KB Output is correct
17 Correct 12 ms 1940 KB Output is correct
18 Correct 9 ms 1996 KB Output is correct
19 Correct 5 ms 1232 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 20 ms 2940 KB Output is correct
22 Correct 19 ms 3000 KB Output is correct
23 Correct 29 ms 4760 KB Output is correct
24 Correct 24 ms 3420 KB Output is correct
25 Correct 43 ms 5288 KB Output is correct