제출 #106156

#제출 시각아이디문제언어결과실행 시간메모리
106156luciocfPipes (BOI13_pipes)C++14
30 / 100
1083 ms132096 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; const int maxm = 5e5+10; typedef pair<int, int> pii; int a[maxn], cur[maxn]; int edge[maxn], costEdge[maxm]; vector<pii> grafo[maxn]; void dfs(int u, int p) { for (auto pp: grafo[u]) { int v = pp.first, e = pp.second; if (v == p) continue; edge[v] = e; dfs(v, u); cur[u] += costEdge[e]/2; } if (u != 1) { costEdge[edge[u]] = 2*(a[u]-cur[u]); cur[u] = a[u]; } } int main(void) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= m; i++) { int u, v; scanf("%d %d", &u, &v); grafo[u].push_back({v, i}); grafo[v].push_back({u, i}); } dfs(1, 0); if (cur[1] != a[1]) printf("0\n"); else { for (int i = 1; i <= m; i++) printf("%d\n", costEdge[i]); } }

컴파일 시 표준 에러 (stderr) 메시지

pipes.cpp: In function 'int main()':
pipes.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
pipes.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...