이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 100004
#define INF 1e9+7
using namespace std;
ll n,m,ar[N],val[N];
vector < vector < pi > > graph(N);
void solvetree(ll cur,ll par,ll edge)
{
rep(i,0,graph[cur].size())
{
ll v = graph[cur][i].first;
if(v == par)
continue;
solvetree(v,cur,graph[cur][i].second);
ar[cur] -= val[graph[cur][i].second];
}
// cout << cur << " " << par << " " << edge << " " << ar[cur] <<endl;
val[edge] = ar[cur];
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> m;
rep(i,1,n+1)
{
cin >> ar[i];
}
rep(i,0,m)
{
ll a,b;
cin >> a >> b;
graph[a].push_back(mp(b,i));
graph[b].push_back(mp(a,i));
}
if(m > n)
{
cout << 0 << endl;
return 0;
}
else if(m == n-1)
{
solvetree(1,1,m);
rep(i,0,m)
{
cout << 2*val[i] << endl;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
pipes.cpp: In function 'void solvetree(long long int, long long int, long long int)':
pipes.cpp:13:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i,a,b) for(int i = a;i < b;i++)
pipes.cpp:24:9:
rep(i,0,graph[cur].size())
~~~~~~~~~~~~~~~~~~~~~
pipes.cpp:24:5: note: in expansion of macro 'rep'
rep(i,0,graph[cur].size())
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |