# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
122499 |
2019-06-28T13:02:43 Z |
SuperJava |
Pipes (BOI13_pipes) |
C++17 |
|
172 ms |
26696 KB |
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define N (200'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)
//global
set<pair<int,int>> s;
set<pair<int,int>> adj[N];
int sum[N];
int val[N];
int main(){
//fold
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout << setprecision(10);
//endfold
int n,m;
cin >> n >> m;
if(m > n) return cout << 0,0;
rep(i,1,n+1){
cin >> sum[i];
}
rep(i,0,m){
int u,v;
cin >> u >> v;
adj[u].insert({v,i});
adj[v].insert({u,i});
}
rep(i,1,n+1){
s.insert({sz(adj[i]),i});
}
while(sz(s) && s.begin()->first == 1){
int u = s.begin()->second;
s.erase(s.begin());
int v = adj[u].begin()->first;
int edgide = adj[u].begin()->second;
adj[u].erase(adj[u].begin());
adj[v].erase({v,edgide});
val[edgide] = sum[u];
sum[u] = 0;
sum[v] -= val[edgide];
}
rep(i,0,m){
cout << val[i]*2 << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
9984 KB |
Output isn't correct |
4 |
Incorrect |
154 ms |
26496 KB |
Output isn't correct |
5 |
Incorrect |
13 ms |
9728 KB |
Output isn't correct |
6 |
Incorrect |
13 ms |
9728 KB |
Output isn't correct |
7 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
8 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
9 |
Incorrect |
11 ms |
9856 KB |
Output isn't correct |
10 |
Incorrect |
11 ms |
9984 KB |
Output isn't correct |
11 |
Incorrect |
10 ms |
9984 KB |
Output isn't correct |
12 |
Incorrect |
10 ms |
9984 KB |
Output isn't correct |
13 |
Incorrect |
115 ms |
23156 KB |
Output isn't correct |
14 |
Incorrect |
128 ms |
25592 KB |
Output isn't correct |
15 |
Incorrect |
142 ms |
26596 KB |
Output isn't correct |
16 |
Incorrect |
119 ms |
23928 KB |
Output isn't correct |
17 |
Incorrect |
139 ms |
26464 KB |
Output isn't correct |
18 |
Incorrect |
169 ms |
26620 KB |
Output isn't correct |
19 |
Incorrect |
128 ms |
26476 KB |
Output isn't correct |
20 |
Incorrect |
11 ms |
9824 KB |
Output isn't correct |
21 |
Incorrect |
11 ms |
9984 KB |
Output isn't correct |
22 |
Incorrect |
154 ms |
26484 KB |
Output isn't correct |
23 |
Incorrect |
126 ms |
23040 KB |
Output isn't correct |
24 |
Incorrect |
142 ms |
26600 KB |
Output isn't correct |
25 |
Incorrect |
125 ms |
23672 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
9728 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
9856 KB |
Output isn't correct |
3 |
Incorrect |
134 ms |
25464 KB |
Output isn't correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
5 |
Correct |
9 ms |
9720 KB |
Output is correct |
6 |
Correct |
10 ms |
9728 KB |
Output is correct |
7 |
Incorrect |
10 ms |
9776 KB |
Output isn't correct |
8 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
9 |
Incorrect |
10 ms |
9728 KB |
Output isn't correct |
10 |
Correct |
9 ms |
9728 KB |
Output is correct |
11 |
Correct |
10 ms |
9728 KB |
Output is correct |
12 |
Correct |
10 ms |
9856 KB |
Output is correct |
13 |
Correct |
11 ms |
9728 KB |
Output is correct |
14 |
Incorrect |
9 ms |
9728 KB |
Output isn't correct |
15 |
Incorrect |
10 ms |
9856 KB |
Output isn't correct |
16 |
Incorrect |
11 ms |
9984 KB |
Output isn't correct |
17 |
Incorrect |
10 ms |
9856 KB |
Output isn't correct |
18 |
Correct |
10 ms |
9728 KB |
Output is correct |
19 |
Correct |
10 ms |
9832 KB |
Output is correct |
20 |
Correct |
10 ms |
9848 KB |
Output is correct |
21 |
Correct |
10 ms |
9728 KB |
Output is correct |
22 |
Incorrect |
11 ms |
9984 KB |
Output isn't correct |
23 |
Incorrect |
119 ms |
23416 KB |
Output isn't correct |
24 |
Incorrect |
137 ms |
26696 KB |
Output isn't correct |
25 |
Incorrect |
132 ms |
25452 KB |
Output isn't correct |
26 |
Correct |
10 ms |
9728 KB |
Output is correct |
27 |
Correct |
16 ms |
9728 KB |
Output is correct |
28 |
Correct |
10 ms |
9728 KB |
Output is correct |
29 |
Correct |
10 ms |
9728 KB |
Output is correct |
30 |
Incorrect |
116 ms |
26212 KB |
Output isn't correct |
31 |
Incorrect |
126 ms |
26488 KB |
Output isn't correct |
32 |
Incorrect |
148 ms |
26424 KB |
Output isn't correct |
33 |
Incorrect |
166 ms |
26552 KB |
Output isn't correct |
34 |
Correct |
10 ms |
9728 KB |
Output is correct |
35 |
Correct |
11 ms |
9856 KB |
Output is correct |
36 |
Correct |
10 ms |
9728 KB |
Output is correct |
37 |
Correct |
11 ms |
9728 KB |
Output is correct |
38 |
Incorrect |
126 ms |
26616 KB |
Output isn't correct |
39 |
Incorrect |
172 ms |
26476 KB |
Output isn't correct |
40 |
Incorrect |
140 ms |
26568 KB |
Output isn't correct |
41 |
Incorrect |
125 ms |
26564 KB |
Output isn't correct |
42 |
Correct |
10 ms |
9728 KB |
Output is correct |
43 |
Correct |
10 ms |
9856 KB |
Output is correct |
44 |
Correct |
11 ms |
9728 KB |
Output is correct |
45 |
Correct |
12 ms |
9728 KB |
Output is correct |
46 |
Incorrect |
129 ms |
26364 KB |
Output isn't correct |
47 |
Incorrect |
135 ms |
26588 KB |
Output isn't correct |
48 |
Incorrect |
118 ms |
26444 KB |
Output isn't correct |
49 |
Incorrect |
163 ms |
25464 KB |
Output isn't correct |
50 |
Correct |
10 ms |
9728 KB |
Output is correct |
51 |
Correct |
11 ms |
9728 KB |
Output is correct |
52 |
Correct |
10 ms |
9728 KB |
Output is correct |
53 |
Correct |
10 ms |
9728 KB |
Output is correct |
54 |
Incorrect |
123 ms |
26232 KB |
Output isn't correct |