# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
94373 | gumball | Pipes (BOI13_pipes) | C++14 | 139 ms | 16820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |