-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD.cpp
More file actions
102 lines (88 loc) · 2.13 KB
/
Copy pathD.cpp
File metadata and controls
102 lines (88 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <bits/stdc++.h>
using namespace std;
#ifndef HELLO_PEOPLE
#define cerr if(0) cout
#endif
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define X first
#define Y second
/* <not-serious> */
template<class T>
struct Nit {
T _v, _s;
Nit(T v, T s) : _v(v), _s(s) {}
operator T &() { return _v; }
T operator *() const { return _v; }
Nit &operator++() { _v += _s; return *this; }
bool operator!=(Nit &a) {
return (_s > 0 ? _v < a._v : _v >= a._v);
}
};
template<class T = int>
struct range {
T _b, _e, _s;
range(T e) : _b(0), _e(e), _s(1) {}
range(T b, T e, T s = 1) : _b(b), _e(e), _s(s) {}
Nit<T> begin() { return Nit<T>(_b, _s); }
Nit<T> end() { return Nit<T>(_e, _s); }
};
template<class T = int>
struct rrange : range<T> {
rrange(T e, T b, T s = 1) : range<T>(e, b, -s) {}
rrange(T e) : range<T>(e, 0, -1) {}
};
template<int D, class T>
struct vec : public vector<vec<D - 1, T>> {
template<class... Args>
vec(int n = 0, Args... a) :
vector<vec<D - 1, T>>(n, vec<D - 1, T>(a...)) {}
};
template<class T>
struct vec<1, T> : public vector<T> {
vec(int n = 0, T const &v = T()) :
vector<T>(n, v) {}
};
template<class T>
inline int constexpr size(T &cont) {
return cont.size();
}
/* </not-serious> */
ll constexpr INF = 1e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vec<2, int> g(n, 0);
for (auto i : range(m)) {
int v, u;
cin >> v >> u;
g[--v].emplace_back(--u);
g[u].emplace_back(v);
}
using pii = pair<int, int>;
vector<pii> a(n);
for (auto i : range(n)) {
cin >> a[i].X;
a[i].Y = i;
}
sort(all(a));
vector<set<int>> cant(n);
for (auto &i : a) {
int j = 1;
for (auto &x : cant[i.Y]) {
if (x == j) j++;
}
if (i.X != j) {
cout << "-1\n";
return 0;
}
for (auto &u : g[i.Y]) {
cant[u].emplace(i.X);
}
}
for (auto &i : a) cout << i.Y + 1 << ' ';
return 0;
}