Submission #94373

# Submission time Handle Problem Language Result Execution time Memory
94373 2019-01-18T02:20:34 Z gumball Pipes (BOI13_pipes) C++14
74.0741 / 100
139 ms 16820 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;
	}
	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: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 7 ms 5212 KB Output is correct
4 Correct 129 ms 14780 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 7 ms 5112 KB Output is correct
10 Correct 7 ms 5244 KB Output is correct
11 Correct 6 ms 5240 KB Output is correct
12 Correct 6 ms 5240 KB Output is correct
13 Correct 89 ms 12920 KB Output is correct
14 Correct 128 ms 14408 KB Output is correct
15 Correct 119 ms 14844 KB Output is correct
16 Correct 99 ms 13432 KB Output is correct
17 Correct 115 ms 14820 KB Output is correct
18 Correct 126 ms 14852 KB Output is correct
19 Correct 139 ms 16820 KB Output is correct
20 Correct 6 ms 5084 KB Output is correct
21 Correct 6 ms 5240 KB Output is correct
22 Correct 112 ms 14816 KB Output is correct
23 Correct 86 ms 12988 KB Output is correct
24 Correct 113 ms 14844 KB Output is correct
25 Correct 99 ms 13304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Incorrect 6 ms 5112 KB Output isn't correct
3 Correct 5 ms 5112 KB Output is correct
4 Correct 5 ms 5112 KB Output is correct
5 Correct 6 ms 5240 KB Output is correct
6 Correct 6 ms 5032 KB Output is correct
7 Incorrect 6 ms 5112 KB Output isn't correct
8 Incorrect 5 ms 5112 KB Output isn't correct
9 Correct 5 ms 5112 KB Output is correct
10 Correct 5 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 5 ms 5116 KB Output is correct
14 Incorrect 5 ms 5112 KB Output isn't correct
15 Incorrect 5 ms 5112 KB Output isn't correct
16 Incorrect 6 ms 5112 KB Output isn't correct
17 Correct 6 ms 5240 KB Output is correct
18 Correct 6 ms 5112 KB Output is correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 1 ms 5112 KB Output is correct
21 Correct 6 ms 5240 KB Output is correct
22 Incorrect 6 ms 5112 KB Output isn't correct
23 Incorrect 6 ms 5112 KB Output isn't correct
24 Incorrect 6 ms 5112 KB Output isn't correct
25 Correct 7 ms 5112 KB Output is correct
26 Correct 6 ms 5112 KB Output is correct
27 Correct 6 ms 5112 KB Output is correct
28 Correct 6 ms 5112 KB Output is correct
29 Correct 6 ms 5112 KB Output is correct
30 Incorrect 6 ms 5112 KB Output isn't correct
31 Incorrect 6 ms 5112 KB Output isn't correct
32 Incorrect 6 ms 5112 KB Output isn't correct
33 Correct 6 ms 5112 KB Output is correct
34 Correct 6 ms 5112 KB Output is correct
35 Correct 6 ms 5112 KB Output is correct
36 Correct 6 ms 5032 KB Output is correct
37 Correct 6 ms 5112 KB Output is correct
38 Incorrect 6 ms 5140 KB Output isn't correct
39 Incorrect 6 ms 5112 KB Output isn't correct
40 Incorrect 5 ms 5112 KB Output isn't correct
41 Correct 5 ms 5112 KB Output is correct
42 Correct 6 ms 5112 KB Output is correct
43 Correct 5 ms 5112 KB Output is correct
44 Correct 5 ms 5112 KB Output is correct
45 Correct 5 ms 5112 KB Output is correct
46 Incorrect 5 ms 5112 KB Output isn't correct
47 Incorrect 5 ms 5112 KB Output isn't correct
48 Incorrect 5 ms 5112 KB Output isn't correct
49 Correct 5 ms 5112 KB Output is correct
50 Correct 6 ms 5112 KB Output is correct
51 Correct 5 ms 5112 KB Output is correct
52 Correct 6 ms 5112 KB Output is correct
53 Correct 6 ms 5112 KB Output is correct
54 Incorrect 6 ms 5112 KB Output isn't correct