Submission #568929

#TimeUsernameProblemLanguageResultExecution timeMemory
568929HappyPacManBridges (APIO19_bridges)C++14
13 / 100
3084 ms7760 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 5e4 + 2; vector<pair<int,int> > adj[maxn]; vector<tuple<int,int,int,int> > edge; bool vis[maxn]; void dfs(int u,int &c){ if(!vis[u]){ vis[u] = true; for(auto [v,w] : adj[u]){ if(w >= c){ dfs(v,c); } } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin >> n >> m; for(int i=1;i<=m;i++){ int u,v,w; cin >> u >> v >> w; edge.emplace_back(u,v,adj[u].size(),adj[v].size()); adj[u].emplace_back(v,w); adj[v].emplace_back(u,w); } int q; cin >> q; while(q--){ int t,x,y; cin >> t >> x >> y; if(t == 1){ int u = get<0>(edge[x-1]); int v = get<1>(edge[x-1]); int ux = get<2>(edge[x-1]); int vx = get<3>(edge[x-1]); adj[u][ux].second = y; adj[v][vx].second = y; }else{ memset(vis,false,sizeof(vis)); dfs(x,y); int r = 0; for(int i=1;i<=n;i++){ r += vis[i]; } cout << r << '\n'; } } }

Compilation message (stderr)

bridges.cpp: In function 'void dfs(int, int&)':
bridges.cpp:11:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   11 |   for(auto [v,w] : adj[u]){
      |            ^
#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...