답안 #94376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94376 2019-01-18T02:37:55 Z gumball Pipes (BOI13_pipes) C++14
39.0741 / 100
136 ms 17292 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:12: 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]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5112 KB Output is correct
2 Correct 5 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 90 ms 15224 KB Output is correct
5 Correct 5 ms 5112 KB Output is correct
6 Correct 5 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 5240 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5244 KB Output is correct
12 Correct 6 ms 5240 KB Output is correct
13 Correct 104 ms 13272 KB Output is correct
14 Correct 114 ms 14684 KB Output is correct
15 Correct 116 ms 15196 KB Output is correct
16 Correct 87 ms 13768 KB Output is correct
17 Correct 95 ms 15224 KB Output is correct
18 Correct 98 ms 15332 KB Output is correct
19 Correct 136 ms 17292 KB Output is correct
20 Correct 5 ms 5112 KB Output is correct
21 Correct 5 ms 5240 KB Output is correct
22 Correct 85 ms 15224 KB Output is correct
23 Correct 68 ms 13432 KB Output is correct
24 Correct 96 ms 15352 KB Output is correct
25 Correct 86 ms 13688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 5112 KB Output isn't correct
2 Incorrect 5 ms 5112 KB Output isn't correct
3 Correct 5 ms 5112 KB Output is correct
4 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
5 Runtime error 10 ms 10080 KB Execution killed with signal 4 (could be triggered by violating memory limits)
6 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
7 Incorrect 5 ms 5112 KB Output isn't correct
8 Incorrect 6 ms 5112 KB Output isn't correct
9 Correct 6 ms 5116 KB Output is correct
10 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
11 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
12 Runtime error 10 ms 9948 KB Execution killed with signal 4 (could be triggered by violating memory limits)
13 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
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 5112 KB Output is correct
18 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
19 Runtime error 11 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
20 Runtime error 10 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
21 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
22 Incorrect 5 ms 5112 KB Output isn't correct
23 Incorrect 5 ms 5112 KB Output isn't correct
24 Incorrect 5 ms 5112 KB Output isn't correct
25 Correct 5 ms 5112 KB Output is correct
26 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
27 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
28 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
29 Runtime error 10 ms 10064 KB Execution killed with signal 4 (could be triggered by violating memory limits)
30 Incorrect 5 ms 5116 KB Output isn't correct
31 Incorrect 5 ms 5112 KB Output isn't correct
32 Incorrect 5 ms 5112 KB Output isn't correct
33 Correct 5 ms 5112 KB Output is correct
34 Runtime error 10 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
35 Runtime error 10 ms 10232 KB Execution killed with signal 4 (could be triggered by violating memory limits)
36 Runtime error 10 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
37 Runtime error 10 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
38 Incorrect 5 ms 5112 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 Runtime error 10 ms 10232 KB Execution killed with signal 4 (could be triggered by violating memory limits)
43 Runtime error 10 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
44 Runtime error 12 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
45 Runtime error 12 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
46 Incorrect 6 ms 5112 KB Output isn't correct
47 Incorrect 6 ms 5112 KB Output isn't correct
48 Incorrect 6 ms 5112 KB Output isn't correct
49 Correct 6 ms 5112 KB Output is correct
50 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
51 Runtime error 11 ms 9976 KB Execution killed with signal 4 (could be triggered by violating memory limits)
52 Runtime error 11 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
53 Runtime error 11 ms 10104 KB Execution killed with signal 4 (could be triggered by violating memory limits)
54 Incorrect 6 ms 5084 KB Output isn't correct