Submission #432659

#TimeUsernameProblemLanguageResultExecution timeMemory
432659inwbearBridges (APIO19_bridges)C++14
13 / 100
153 ms488 KiB
#include <bits/stdc++.h> using namespace std; int n,m,pa[1005][3],qq,a,b,c,ans; bool vis[1005]; vector<pair<int,int> >v[1005]; queue<int>q; int main() { //freopen("test.cpp","r",stdin); scanf("%d %d",&n,&m); for(int i=1;i<=m;i++) { scanf("%d %d %d",&pa[i][0],&pa[i][1],&pa[i][2]); } scanf("%d",&qq); while(qq--) { scanf("%d %d %d",&a,&b,&c); if(a==1) { pa[b][2]=c; } else { ans=0; for(int i=1;i<=n;i++)v[i].clear(),vis[i]=false; for(int i=1;i<=m;i++)v[pa[i][0]].push_back({pa[i][1],pa[i][2]}),v[pa[i][1]].push_back({pa[i][0],pa[i][2]}); q.push(b); while(!q.empty()) { ans++; a=q.front(); q.pop(); for(int i=0;i<v[a].size();i++) { if(!vis[v[a][i].first]&&c<=v[a][i].second) { vis[v[a][i].first]=true; q.push(v[a][i].first); } } } printf("%d\n",max(ans-1,1)); } } }

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:34:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 for(int i=0;i<v[a].size();i++)
      |                             ~^~~~~~~~~~~~
bridges.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bridges.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d %d %d",&pa[i][0],&pa[i][1],&pa[i][2]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d",&qq);
      |     ~~~~~^~~~~~~~~~
bridges.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d %d %d",&a,&b,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...