Submission #78682

#TimeUsernameProblemLanguageResultExecution timeMemory
78682Charis02Pipes (BOI13_pipes)C++14
65 / 100
343 ms119032 KiB
#include<iostream> #include<stdio.h> #include<vector> #include<cmath> #include<queue> #include<string.h> #include<map> #include<set> #include<algorithm> #define ll long long #define pi pair < ll,ll > #define mp(a,b) make_pair(a,b) #define rep(i,a,b) for(int i = a;i < b;i++) #define N 100004 #define INF 1e9+7 using namespace std; ll n,m,ar[N],val[N]; vector < vector < pi > > graph(N); void solvetree(ll cur,ll par,ll edge) { rep(i,0,graph[cur].size()) { ll v = graph[cur][i].first; if(v == par) continue; solvetree(v,cur,graph[cur][i].second); ar[cur] -= val[graph[cur][i].second]; } // cout << cur << " " << par << " " << edge << " " << ar[cur] <<endl; val[edge] = ar[cur]; return; } int main() { ios_base::sync_with_stdio(false); cin >> n >> m; rep(i,1,n+1) { cin >> ar[i]; } rep(i,0,m) { ll a,b; cin >> a >> b; graph[a].push_back(mp(b,i)); graph[b].push_back(mp(a,i)); } if(m > n) { cout << 0 << endl; return 0; } else if(m == n-1) { solvetree(1,1,m); rep(i,0,m) { cout << 2*val[i] << endl; } } return 0; }

Compilation message (stderr)

pipes.cpp: In function 'void solvetree(long long int, long long int, long long int)':
pipes.cpp:13:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,a,b) for(int i = a;i < b;i++)
pipes.cpp:24:9:
     rep(i,0,graph[cur].size())
         ~~~~~~~~~~~~~~~~~~~~~       
pipes.cpp:24:5: note: in expansion of macro 'rep'
     rep(i,0,graph[cur].size())
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...