Submission #252139

#TimeUsernameProblemLanguageResultExecution timeMemory
252139ErkhemkhuuBridges (APIO19_bridges)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const ll N = 1005; bool vis[N]; tuple <ll, ll, ll> brid[N]; vector <vector <ll> > adj(N); vector <ll> wp[N][N]; ll dfs(ll v, ll w) { ll ans = 1; vis[v] = true; for(auto &u: adj[v]) if(vis[u]) continue; for(auto &x: wp[v][u]) if(w <= x) ans += dfs(u, w); return ans; } int main() { ll n, m, i, v, u, w, q, t, l, r; cin >> n >> m; for(i = 0; i < m; i++) { cin >> v >> u >> w; v--; u--; adj[v].pb(u); adj[u].pb(v); wp[v][u].pb(w); wp[u][v].pb(w); brid[i] = {v, u, wp[v][u].size() - 1}; } cin >> q; while(q--) { cin >> t >> l >> r; l--; if(t == 1) { auto temp = brid[l]; ll x = get <0> (temp); ll y = get <1> (temp); ll z = get <2> (temp); wp[x][y][z] = wp[y][x][z] = r; } else { memset(vis, false, sizeof(vis)); cout << dfs(l, r) << "\n"; } } return 0; }

Compilation message (stderr)

bridges.cpp: In function 'long long int dfs(long long int, long long int)':
bridges.cpp:16:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(auto &u: adj[v])
     ^~~
bridges.cpp:18:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for(auto &x: wp[v][u])
         ^~~
bridges.cpp:18:28: error: 'u' was not declared in this scope
         for(auto &x: wp[v][u])
                            ^