Submission #57432

#TimeUsernameProblemLanguageResultExecution timeMemory
57432dakara2006줄서기 (KOI17_line)C++98
7 / 100
1071 ms708 KiB
#include <bits/stdc++.h> using namespace std; pair<int,int> a[100005]; int arr[100005],num[100005],cnt,i,j,hap; int main() { int n,m; scanf("%d %d",&n,&m); for(i=0;i<m;i++) { scanf("%d %d",&a[i].first,&a[i].second); } for(i=0;i<n;i++) arr[i]=i+1; do { cnt=0; for(i=0;i<m;i++) { if(arr[a[i].first-1]>arr[a[i].second-1]) cnt++; else break; } if(cnt==m) { cnt=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(arr[i]>arr[j]) cnt++; } } if(cnt==m) { hap=0; for(i=0;i<n;i++) { num[i]=arr[i]; hap+=num[i]; } } } }while(next_permutation(arr,arr+n)); if(hap==0) { printf("-1"); return 0; } for(i=0;i<n;i++) { printf("%d ",num[i]); } return 0; }

Compilation message (stderr)

line.cpp: In function 'int main()':
line.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
line.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a[i].first,&a[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...