Submission #111618

# Submission time Handle Problem Language Result Execution time Memory
111618 2019-05-15T17:55:37 Z rajarshi_basu Pipes (BOI13_pipes) C++14
65 / 100
307 ms 10872 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <complex>
#include <stack>
#include <set>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 

const int INF = 1e9;
using namespace std;
const int MAXN = 100*1000 +5;

int nodeVal[MAXN];
int edgesVal[MAXN];
bool marked[MAXN];
vector<ii> g[MAXN];

void dfs(int node,int p,int pe){
	for(auto e:g[node]){
		if(e.ff != p){
			dfs(e.ff,node,e.ss);
			nodeVal[node] -= nodeVal[e.ff];
		}
	}
	if(pe > -1){
		edgesVal[pe] = nodeVal[node];
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	if(m > n){
		cout << "0" << endl;
	}else if(m < n){
		FOR(i,n)cin >> nodeVal[i];
		FOR(i,m){
			int a,b;
			cin >> a >> b;
			a--;b--;
			g[a].pb({b,i});
			g[b].pb({a,i});
		}
		dfs(0,-1,-1);
		FOR(i,m){
			cout << 2*edgesVal[i] << endl;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 7 ms 2816 KB Output is correct
4 Correct 304 ms 7644 KB Output is correct
5 Correct 5 ms 2688 KB Output is correct
6 Correct 4 ms 2688 KB Output is correct
7 Correct 5 ms 2688 KB Output is correct
8 Correct 5 ms 2688 KB Output is correct
9 Correct 7 ms 2688 KB Output is correct
10 Correct 8 ms 2688 KB Output is correct
11 Correct 7 ms 2688 KB Output is correct
12 Correct 7 ms 2816 KB Output is correct
13 Correct 233 ms 6576 KB Output is correct
14 Correct 296 ms 7360 KB Output is correct
15 Correct 307 ms 7616 KB Output is correct
16 Correct 251 ms 6944 KB Output is correct
17 Correct 272 ms 7672 KB Output is correct
18 Correct 299 ms 7756 KB Output is correct
19 Correct 307 ms 10872 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 7 ms 2688 KB Output is correct
22 Correct 264 ms 7708 KB Output is correct
23 Correct 232 ms 6756 KB Output is correct
24 Correct 280 ms 7624 KB Output is correct
25 Correct 276 ms 6956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Incorrect 3 ms 2688 KB Output isn't correct
3 Incorrect 4 ms 2688 KB Output isn't correct
4 Correct 4 ms 2688 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 5 ms 2688 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Incorrect 3 ms 2688 KB Output isn't correct
9 Incorrect 3 ms 2688 KB Output isn't correct
10 Correct 4 ms 2688 KB Output is correct
11 Correct 4 ms 2688 KB Output is correct
12 Correct 4 ms 2688 KB Output is correct
13 Correct 3 ms 2688 KB Output is correct
14 Incorrect 5 ms 2688 KB Output isn't correct
15 Incorrect 4 ms 2688 KB Output isn't correct
16 Incorrect 3 ms 2688 KB Output isn't correct
17 Incorrect 4 ms 2688 KB Output isn't correct
18 Correct 5 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Incorrect 4 ms 2688 KB Output isn't correct
23 Incorrect 4 ms 2688 KB Output isn't correct
24 Incorrect 4 ms 2716 KB Output isn't correct
25 Incorrect 3 ms 2688 KB Output isn't correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 4 ms 2688 KB Output is correct
29 Correct 3 ms 2688 KB Output is correct
30 Incorrect 4 ms 2764 KB Output isn't correct
31 Incorrect 4 ms 2688 KB Output isn't correct
32 Incorrect 4 ms 2688 KB Output isn't correct
33 Incorrect 5 ms 2688 KB Output isn't correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 5 ms 2688 KB Output is correct
36 Correct 5 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Incorrect 4 ms 2688 KB Output isn't correct
39 Incorrect 4 ms 2688 KB Output isn't correct
40 Incorrect 4 ms 2688 KB Output isn't correct
41 Incorrect 4 ms 2688 KB Output isn't correct
42 Correct 5 ms 2688 KB Output is correct
43 Correct 3 ms 2688 KB Output is correct
44 Correct 4 ms 2660 KB Output is correct
45 Correct 3 ms 2688 KB Output is correct
46 Incorrect 4 ms 2688 KB Output isn't correct
47 Incorrect 5 ms 2688 KB Output isn't correct
48 Incorrect 4 ms 2688 KB Output isn't correct
49 Incorrect 4 ms 2688 KB Output isn't correct
50 Correct 6 ms 2688 KB Output is correct
51 Correct 4 ms 2688 KB Output is correct
52 Correct 5 ms 2688 KB Output is correct
53 Correct 4 ms 2688 KB Output is correct
54 Incorrect 5 ms 2764 KB Output isn't correct