Submission #26389

#TimeUsernameProblemLanguageResultExecution timeMemory
26389samir_droubiPipes (BOI13_pipes)C++14
44.07 / 100
656 ms56304 KiB
#include <bits/stdc++.h> using namespace std; int n,m; const int mxn=(1e5)+5; long long c[mxn]; set<pair<int,int> > s; set<pair<int,int> >gr[mxn]; int ans[mxn*5]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) scanf("%d",&c[i]); for(int i=1;i<=m;++i) { int x,y; scanf("%d%d",&x,&y); gr[x].insert({y,i}); gr[y].insert({x,i}); } if(m>=n) { puts("0"); return 0; } for(int i=1;i<=n;++i) s.insert({gr[i].size(),i}); while(!s.empty()) { int v=s.begin()->second; int u=gr[v].begin()->first; int in=gr[v].begin()->second; s.erase(s.begin()); gr[u].erase({v,in}); ans[in]=2*c[v]; c[u]-=c[v]; } for(int i=1;i<=m;++i)printf("%d\n",ans[i]); return 0; }

Compilation message (stderr)

pipes.cpp: In function 'int main()':
pipes.cpp:13:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%d",&c[i]);
                   ^
pipes.cpp:11:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
pipes.cpp:13:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&c[i]);
                    ^
pipes.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...