#include <bits/stdc++.h>
using namespace std;
int A[100005];
int chk[100005];
int n, m;
signed main()
{
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++) A[i] = i;
for (int i = 1; i <= m; i++)
{
int a, b; cin >> a >> b;
A[a]++, A[b]--;
}
for (int i = 1; i <= n; i++)
{
if (A[i] <= 0 || A[i] > n || chk[A[i]]) { cout << -1; return 0; }
chk[A[i]] = 1;
}
for (int i = 1; i <= n; i++) cout << A[i] << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
6 ms |
596 KB |
Output is correct |
24 |
Correct |
13 ms |
956 KB |
Output is correct |
25 |
Correct |
80 ms |
3892 KB |
Output is correct |
26 |
Correct |
19 ms |
1224 KB |
Output is correct |
27 |
Correct |
44 ms |
3276 KB |
Output is correct |
28 |
Correct |
47 ms |
3524 KB |
Output is correct |
29 |
Correct |
88 ms |
6344 KB |
Output is correct |
30 |
Correct |
120 ms |
9040 KB |
Output is correct |
31 |
Correct |
60 ms |
3916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
6 ms |
596 KB |
Output is correct |
24 |
Correct |
13 ms |
956 KB |
Output is correct |
25 |
Correct |
80 ms |
3892 KB |
Output is correct |
26 |
Correct |
19 ms |
1224 KB |
Output is correct |
27 |
Correct |
44 ms |
3276 KB |
Output is correct |
28 |
Correct |
47 ms |
3524 KB |
Output is correct |
29 |
Correct |
88 ms |
6344 KB |
Output is correct |
30 |
Correct |
120 ms |
9040 KB |
Output is correct |
31 |
Correct |
60 ms |
3916 KB |
Output is correct |
32 |
Correct |
122 ms |
4584 KB |
Output is correct |
33 |
Correct |
70 ms |
5648 KB |
Output is correct |
34 |
Correct |
127 ms |
8936 KB |
Output is correct |
35 |
Correct |
93 ms |
8024 KB |
Output is correct |
36 |
Correct |
128 ms |
8996 KB |
Output is correct |
37 |
Correct |
141 ms |
11304 KB |
Output is correct |
38 |
Correct |
130 ms |
11192 KB |
Output is correct |
39 |
Correct |
193 ms |
12828 KB |
Output is correct |
40 |
Correct |
148 ms |
12456 KB |
Output is correct |