This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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] << ' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |