# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57436 | praha0518 | 줄서기 (KOI17_line) | C++98 | 1069 ms | 544 KiB |
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 n,m;
int arr[10];
int x[40],y[40];
int main()
{
int i , j;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++) scanf("%d %d",&x[i],&y[i]);
for(i=0;i<n;i++) arr[i] = i+1; //1 2 3 4 . . . 9
do
{
// 1
bool good = true;
for(i=0;i<m;i++)
{
if(arr[x[i]-1]<arr[y[i]-1]) good = false;
}
// 2
int cnt = 0;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(arr[i]>arr[j]) cnt++;
}
}
if(cnt!=m) good = false;
// result
if(good)
{
for(i=0;i<n;i++) printf("%d ",arr[i]);
printf("\n");
return 0;
}
} while(next_permutation(arr,arr+n));
printf("-1\n");
return 0;
}
Compilation message (stderr)
# | 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... |