Submission #910801

#TimeUsernameProblemLanguageResultExecution timeMemory
910801ibm2006Bridges (APIO19_bridges)C++17
13 / 100
3071 ms45900 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,m,e,ee,a[1100000],c[1100000],h[1100000];
pair<ll,ll> p[1100000],q[1100000];
vector<pair<ll,ll>> v[1100000];
ll dfs(ll x,ll y)
{
    ll i,s=0;
    c[x]=1;
    s++;
    for(i=0;i<h[x];i++)
    {
        if(c[v[x][i].first]==1||v[x][i].second<y)
            continue;
        s+=dfs(v[x][i].first,y);
    }
    return s;
}
ll f(ll x,ll y)
{
    ll i;
    for(i=1;i<=n;i++)
    {
        c[i]=0;
    }
    //printf("!");
    return dfs(x,y);
}
int main()
{
    scanf("%lld %lld",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%lld %lld %lld",&x,&y,&z);
        v[x].push_back({y,z});
        v[y].push_back({x,z});
        p[i]={x,y};
        q[i]={h[x],h[y]};
        h[x]++;
        h[y]++;
    }
    scanf("%lld",&e);
    for(ee=0;ee<e;ee++)
    {
        scanf("%lld",&x);
        if(x==1)
        {
            scanf("%lld %lld",&x,&y);
            v[p[x].first][q[x].first].second=y;
            v[p[x].second][q[x].second].second=y;
            continue;
        }
        scanf("%lld %lld",&x,&y);
        printf("%lld\n",f(x,y));
    }
}

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%lld %lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
bridges.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%lld %lld %lld",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%lld",&e);
      |     ~~~~~^~~~~~~~~~~
bridges.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
bridges.cpp:49:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |             scanf("%lld %lld",&x,&y);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
bridges.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         scanf("%lld %lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...