답안 #81501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81501 2018-10-25T06:29:44 Z antimirage Pipes (BOI13_pipes) C++17
0 / 100
172 ms 12300 KB
#include <bits/stdc++.h>

#define mk make_pair
#define pb push_back
#define fr first
#define sc second

using namespace std;

const int N = 1e5 + 5;

long long n, m, ar[N], x, y, ans[N], sup[N];

vector < vector < pair <int, int> > > g;

void dfs (int v, int p = 0)
{
	for (auto to : g[v])
	{
		if (to.fr == p) continue;
		dfs(to.fr, v);
		ans[to.sc] = ar[to.fr] - sup[to.fr];
		sup[v] += ar[to.fr] - sup[to.fr];
	}
}

int main() 
{
	cin >> n >> m;
	g.resize(n + 1);
	
	assert(n - 1 == m);
	
	for (int i = 1; i <= n; i++)
		scanf("%I64d", &ar[i]);
		
	for (int i = 1; i <= m; i++)
	{
		scanf("%I64d%I64d", &x, &y);
		g[x].pb(mk(y,i) );
		g[y].pb(mk(x,i) );
	}
	dfs(1);
	puts("0");
	/**if (ar[1] != sup[1])
	{
		puts("0");
		return 0;
	}
	for (int i = 1; i <= m; i++)
	{
		if(ans[i] * 2 > 1e9 || ans[i] * 2 < -1e9)
		{
			puts("0");
			return 0;
		}
	}
	for (int i = 1; i <= m; i++)
		printf("%I64d\n", ans[i] * 2);**/
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:35:24: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%I64d", &ar[i]);
                  ~~~~~~^
pipes.cpp:39:29: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%I64d%I64d", &x, &y);
                       ~~    ^
pipes.cpp:39:29: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
pipes.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%I64d", &ar[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%I64d%I64d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Incorrect 16 ms 748 KB Output isn't correct
4 Incorrect 171 ms 8928 KB Output isn't correct
5 Incorrect 2 ms 8928 KB Output isn't correct
6 Incorrect 2 ms 8928 KB Output isn't correct
7 Incorrect 2 ms 8928 KB Output isn't correct
8 Incorrect 2 ms 8928 KB Output isn't correct
9 Incorrect 3 ms 8928 KB Output isn't correct
10 Incorrect 4 ms 8928 KB Output isn't correct
11 Incorrect 5 ms 8928 KB Output isn't correct
12 Incorrect 3 ms 8928 KB Output isn't correct
13 Incorrect 136 ms 8928 KB Output isn't correct
14 Incorrect 164 ms 8928 KB Output isn't correct
15 Incorrect 153 ms 8940 KB Output isn't correct
16 Incorrect 132 ms 8940 KB Output isn't correct
17 Incorrect 172 ms 8996 KB Output isn't correct
18 Incorrect 164 ms 9052 KB Output isn't correct
19 Incorrect 168 ms 12300 KB Output isn't correct
20 Incorrect 2 ms 12300 KB Output isn't correct
21 Incorrect 4 ms 12300 KB Output isn't correct
22 Incorrect 160 ms 12300 KB Output isn't correct
23 Incorrect 132 ms 12300 KB Output isn't correct
24 Incorrect 164 ms 12300 KB Output isn't correct
25 Incorrect 132 ms 12300 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 6 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 2 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 3 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 6 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 9 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
43 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
44 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 5 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Runtime error 8 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
51 Runtime error 7 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
52 Runtime error 9 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 6 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 9 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)