Submission #114765

# Submission time Handle Problem Language Result Execution time Memory
114765 2019-06-02T15:35:17 Z luciocf Pipes (BOI13_pipes) C++14
30 / 100
1000 ms 131072 KB
#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);
 
	for (int i = 1; i <= m; i++)
		printf("%d\n", costEdge[i]);
}

Compilation message

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 time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 23 ms 2688 KB Output is correct
3 Correct 5 ms 2816 KB Output is correct
4 Correct 94 ms 10036 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 5 ms 2688 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 4 ms 2688 KB Output is correct
9 Correct 4 ms 2816 KB Output is correct
10 Correct 5 ms 2816 KB Output is correct
11 Correct 5 ms 2816 KB Output is correct
12 Correct 4 ms 2816 KB Output is correct
13 Correct 60 ms 8568 KB Output is correct
14 Correct 83 ms 9592 KB Output is correct
15 Correct 81 ms 9976 KB Output is correct
16 Correct 64 ms 8952 KB Output is correct
17 Correct 81 ms 9976 KB Output is correct
18 Correct 80 ms 10052 KB Output is correct
19 Correct 96 ms 12536 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2816 KB Output is correct
22 Correct 79 ms 10104 KB Output is correct
23 Correct 65 ms 8484 KB Output is correct
24 Correct 91 ms 9976 KB Output is correct
25 Correct 66 ms 8824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 124 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 622 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 504 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 195 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 364 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 119 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 166 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 115 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 110 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 113 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 114 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 112 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 125 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 130 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 134 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 133 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 152 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 124 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 120 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 117 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 122 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 639 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 855 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 832 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 671 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 494 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 177 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 317 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 771 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 533 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 909 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 525 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 280 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 511 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 181 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 450 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 651 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Execution timed out 1073 ms 106584 KB Time limit exceeded
40 Runtime error 532 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 535 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 487 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Runtime error 631 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
44 Runtime error 218 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
45 Runtime error 333 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
46 Execution timed out 1082 ms 106232 KB Time limit exceeded
47 Runtime error 786 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
48 Runtime error 705 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
49 Runtime error 1022 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Runtime error 466 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
51 Runtime error 715 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
52 Runtime error 270 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
53 Runtime error 301 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
54 Runtime error 562 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)