Submission #1119008

#TimeUsernameProblemLanguageResultExecution timeMemory
1119008PagodePaivaBridges (APIO19_bridges)C++17
13 / 100
38 ms848 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1010; vector <pair <int, int>> g[N]; array<int, 4> ordem_arestas[N]; int mark[N]; void update(int i, int w){ auto [a, pa, b, pb] = ordem_arestas[i]; g[a][pa].second = w; g[b][pb].second = w; return; } int con; void dfs(int v, int w){ if(mark[v]) return; mark[v] = 1; con++; for(auto [x, p] : g[v]){ if(p < w) continue; dfs(x, w); } return; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, q; cin >> n >> m; for(int i = 0;i < m;i++){ int a, b, w; cin >> a >> b >> w; ordem_arestas[i+1] = {a, g[a].size(), b, g[b].size()}; g[a].push_back({b, w}); g[b].push_back({a, w}); } cin >> q; while(q--){ int t; cin >> t; if(t == 2){ int s, w; cin >> s >> w; memset(mark, 0, sizeof mark); con = 0; dfs(s, w); cout << con << '\n'; } else{ int idx, w; cin >> idx >> w; update(idx, w); } } }

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:37:43: warning: narrowing conversion of 'g[a].std::vector<std::pair<int, int> >::size()' from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   37 |         ordem_arestas[i+1] = {a, g[a].size(), b, g[b].size()};
      |                                  ~~~~~~~~~^~
bridges.cpp:37:59: warning: narrowing conversion of 'g[b].std::vector<std::pair<int, int> >::size()' from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   37 |         ordem_arestas[i+1] = {a, g[a].size(), b, g[b].size()};
      |                                                  ~~~~~~~~~^~
#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...