제출 #802316

#제출 시각아이디문제언어결과실행 시간메모리
802316tch1cherinPipes (BOI13_pipes)C++17
30 / 100
323 ms131076 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; vector<pair<int, int>> G[MAX_N]; int c[MAX_N], x[MAX_N]; void DFS(int u, int p) { for (auto [v, i] : G[u]) { if (v != p) { DFS(v, u); x[i] = c[v]; c[u] -= x[i]; } } } int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M; cin >> N >> M; for (int i = 0; i < N; i++) { cin >> c[i]; } for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; u--, v--; G[u].push_back({v, i}); G[v].push_back({u, i}); } DFS(0, -1); for (int i = 0; i < M; i++) { cout << x[i] * 2 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...