Submission #728098

#TimeUsernameProblemLanguageResultExecution timeMemory
728098Username4132Bridges (APIO19_bridges)C++14
13 / 100
3053 ms9280 KiB
#include<iostream>
#include<vector>
using namespace std;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define PB push_back
#define F first
#define S second

int n, m, q, weight[100010];
bool vis[50010];
vector<pii> g[50010];

int dfs(int v, int w){
    int ret=1;
    vis[v]=true;
    for(pii to:g[v]) if(!vis[to.F] && weight[to.S]>=w) ret+=dfs(to.F, w);
    return ret;
}

int main(){
    scanf("%d %d", &n, &m);
    forn(i, m){
        int a, b, c; scanf("%d %d %d", &a, &b, &c); --a, --b;
        g[a].PB({b, i}), g[b].PB({a, i});
        weight[i]=c;
    }
    scanf("%d", &q);
    forn(qnum, q){
        int a, b, c; scanf("%d %d %d", &a, &b, &c), --b;
        if(a==1) weight[b]=c;
        else{
            printf("%d\n", dfs(b, c));
            forn(i, n) vis[i]=false;
        }
    }
}

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bridges.cpp:24:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         int a, b, c; scanf("%d %d %d", &a, &b, &c); --a, --b;
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
bridges.cpp:30:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         int a, b, c; scanf("%d %d %d", &a, &b, &c), --b;
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...