Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- vector<int> I(m), J(m), C(m);
- for (int i = 0; i < m; ++i) {
- cin >> I[i];
- }
- for (int i = 0; i < m; ++i) {
- cin >> J[i];
- }
- for (int i = 0; i < m; ++i) {
- cin >> C[i];
- }
- vector<int> H(n, -1), L(m, -1);
- for (int k = 0; k < m; ++k) {
- int j = J[k];
- L[k] = H[j];
- H[j] = k;
- }
- cout << "H: ";
- for (auto x : H) {
- cout << x << " ";
- }
- cout << endl;
- cout << "L: ";
- for (auto x : L) {
- cout << x << " ";
- }
- cout << endl;
- int inf = 1e9;
- for (int i = 0; i < n; ++i) {
- cout << "v " << i << ": ";
- int min_cost = inf;
- int max_cost = 0;
- for (int k = H[i]; k != -1; k = L[k]) {
- int j = J[k];
- int c = C[k];
- min_cost = min(min_cost, c);
- max_cost = max(max_cost, c);
- }
- int del = max_cost - min_cost;
- if (del != -inf) cout << del << endl;
- else cout << "no edjes" << endl;
- }
- }
- /*
- 4 5
- 0 1 2 1 0
- 1 2 3 3 2
- 0 1 2 3 4
- */
Advertisement
Add Comment
Please, Sign In to add comment