Submission #432868

#TimeUsernameProblemLanguageResultExecution timeMemory
432868AmylopectinBridges (APIO19_bridges)C++14
13 / 100
3067 ms11868 KiB
#include <iostream> #include <stdio.h> #include <vector> using namespace std; const int mxn = 1e5 + 10; struct we { int to,dis; }; struct pat { int fr,to,fri,toi; }; struct pat pli[mxn] = {}; vector<struct we> pa[mxn] = {}; int u[mxn] = {},cou; int re(int cn,int wei,int fla) { int i,fn; u[cn] = fla; cou ++; for(i=0; i<pa[cn].size(); i++) { fn = pa[cn][i].to; if(u[fn] == fla || pa[cn][i].dis < wei) { continue; } re(fn,wei,fla); } return 0; } int main() { int i,j,n,m,f,t,cdi,cn,fn,q,cst; scanf("%d %d",&n,&m); for(i=1; i<=m; i++) { scanf("%d %d %d",&f,&t,&cdi); pli[i] = {f,t,pa[f].size(),pa[t].size()}; pa[f].push_back({t,cdi}); pa[t].push_back({f,cdi}); } scanf("%d",&q); for(i=1; i<=q; i++) { scanf("%d %d %d",&cst,&f,&t); if(cst == 1) { pa[pli[f].fr][pli[f].fri].dis = t; pa[pli[f].to][pli[f].toi].dis = t; } else { cou = 0; re(f,t,i); printf("%d\n",cou); } } return 0; }

Compilation message (stderr)

bridges.cpp: In function 'int re(int, int, int)':
bridges.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<we>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(i=0; i<pa[cn].size(); i++)
      |              ~^~~~~~~~~~~~~~
bridges.cpp: In function 'int main()':
bridges.cpp:40:33: warning: narrowing conversion of 'pa[f].std::vector<we>::size()' from 'std::vector<we>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   40 |         pli[i] = {f,t,pa[f].size(),pa[t].size()};
      |                       ~~~~~~~~~~^~
bridges.cpp:40:46: warning: narrowing conversion of 'pa[t].std::vector<we>::size()' from 'std::vector<we>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   40 |         pli[i] = {f,t,pa[f].size(),pa[t].size()};
      |                                    ~~~~~~~~~~^~
bridges.cpp:35:11: warning: unused variable 'j' [-Wunused-variable]
   35 |     int i,j,n,m,f,t,cdi,cn,fn,q,cst;
      |           ^
bridges.cpp:35:25: warning: unused variable 'cn' [-Wunused-variable]
   35 |     int i,j,n,m,f,t,cdi,cn,fn,q,cst;
      |                         ^~
bridges.cpp:35:28: warning: unused variable 'fn' [-Wunused-variable]
   35 |     int i,j,n,m,f,t,cdi,cn,fn,q,cst;
      |                            ^~
bridges.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bridges.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%d %d %d",&f,&t,&cdi);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
bridges.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d %d %d",&cst,&f,&t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...