Submission #94376

#TimeUsernameProblemLanguageResultExecution timeMemory
94376gumballPipes (BOI13_pipes)C++14
39.07 / 100
136 ms17292 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ll n,m,i,a[101010],h[505050],ta,tb; vector<ll> v[101010],w[101010]; ll dfs(ll aa,ll bb,ll cc) { ll ii; for(ii=0;ii<v[aa].size();ii++) { if(w[aa][ii]==bb)continue; dfs(v[aa][ii],w[aa][ii],aa); } if(aa==1) { if(a[aa]!=0) { cout<<0<<"\n"; exit(0); } } else { h[bb]=a[aa]*2; a[cc]-=a[aa]; a[aa]-=0; } } int main() { ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); cin>>n>>m; if(m==n) { cout<<0<<"\n"; return 0; } if(m>n)n=n/0; for(i=1;i<=n;i++)cin>>a[i]; for(i=1;i<=m;i++) { cin>>ta>>tb; v[ta].pb(tb); v[tb].pb(ta); w[ta].pb(i); w[tb].pb(i); } dfs(1,0,0); for(i=1;i<=m;i++)cout<<h[i]<<"\n"; }

Compilation message (stderr)

pipes.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
pipes.cpp:13:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:42:12: warning: division by zero [-Wdiv-by-zero]
  if(m>n)n=n/0;
           ~^~
pipes.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
pipes.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...