Submission #94377

# Submission time Handle Problem Language Result Execution time Memory
94377 2019-01-18T02:38:29 Z gumball Pipes (BOI13_pipes) C++14
65 / 100
136 ms 16524 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,a[101010],h[505050],ta,tb;
vector<ll> v[101010],w[101010];
ll dfs(ll aa,ll bb,ll cc)
{
	ll ii;
	for(ii=0;ii<v[aa].size();ii++)
	{
		if(w[aa][ii]==bb)continue;
		dfs(v[aa][ii],w[aa][ii],aa);
	}
	if(aa==1)
	{
		if(a[aa]!=0)
		{
			cout<<0<<"\n";
			exit(0);
		}
	}
	else
	{
		h[bb]=a[aa]*2;
		a[cc]-=a[aa];
		a[aa]-=0;
	}
}
int main()
{
	ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	if(m>n)
	{
		cout<<0<<"\n";
		return 0;
	}
	if(m==n)n=n/0;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=m;i++)
	{
		cin>>ta>>tb;
		v[ta].pb(tb);
		v[tb].pb(ta);
		w[ta].pb(i);
		w[tb].pb(i);
	}
	dfs(1,0,0);
	for(i=1;i<=m;i++)cout<<h[i]<<"\n";
}

Compilation message

pipes.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
pipes.cpp:13:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:42:13: warning: division by zero [-Wdiv-by-zero]
  if(m==n)n=n/0;
            ~^~
pipes.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
pipes.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 122 ms 14584 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5244 KB Output is correct
10 Correct 6 ms 5240 KB Output is correct
11 Correct 7 ms 5240 KB Output is correct
12 Correct 6 ms 5240 KB Output is correct
13 Correct 99 ms 12792 KB Output is correct
14 Correct 110 ms 14160 KB Output is correct
15 Correct 132 ms 14584 KB Output is correct
16 Correct 107 ms 13156 KB Output is correct
17 Correct 124 ms 14528 KB Output is correct
18 Correct 115 ms 14584 KB Output is correct
19 Correct 128 ms 16524 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 7 ms 5240 KB Output is correct
22 Correct 129 ms 14648 KB Output is correct
23 Correct 104 ms 12628 KB Output is correct
24 Correct 136 ms 14584 KB Output is correct
25 Correct 87 ms 13020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
2 Runtime error 11 ms 10076 KB Execution killed with signal 4 (could be triggered by violating memory limits)
3 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
8 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
9 Runtime error 10 ms 9980 KB Execution killed with signal 4 (could be triggered by violating memory limits)
10 Correct 6 ms 5112 KB Output is correct
11 Correct 5 ms 5112 KB Output is correct
12 Correct 5 ms 5112 KB Output is correct
13 Correct 6 ms 5112 KB Output is correct
14 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
15 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
16 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
17 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
18 Correct 5 ms 5112 KB Output is correct
19 Correct 5 ms 5116 KB Output is correct
20 Correct 5 ms 5112 KB Output is correct
21 Correct 6 ms 5116 KB Output is correct
22 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
23 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
24 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
25 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
26 Correct 5 ms 5112 KB Output is correct
27 Correct 5 ms 5112 KB Output is correct
28 Correct 5 ms 5112 KB Output is correct
29 Correct 6 ms 5112 KB Output is correct
30 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
31 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
32 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
33 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
34 Correct 6 ms 5112 KB Output is correct
35 Correct 6 ms 5084 KB Output is correct
36 Correct 6 ms 5112 KB Output is correct
37 Correct 6 ms 5112 KB Output is correct
38 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
39 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
40 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
41 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
42 Correct 6 ms 5112 KB Output is correct
43 Correct 6 ms 5112 KB Output is correct
44 Correct 5 ms 5112 KB Output is correct
45 Correct 6 ms 5112 KB Output is correct
46 Runtime error 12 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
47 Runtime error 11 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
48 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
49 Runtime error 11 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
50 Correct 6 ms 5112 KB Output is correct
51 Correct 6 ms 5112 KB Output is correct
52 Correct 6 ms 5112 KB Output is correct
53 Correct 6 ms 5084 KB Output is correct
54 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)