# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893430 | vjudge1 | Event Hopping 2 (JOI21_event2) | C++17 | 53 ms | 1884 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>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
int n,k;
cin>>n>>k;
vector <int> a(n),b(n);
for(int i=0;i<n;i++)cin>>a[i]>>b[i];
for(int i=0;i<(1<<n);i++){
vector <pair <int,int> > v;
for(int j=0;j<n;j++){
if((i & (1<<j))!=0){
v.pb({a[j],b[j]});
}
}
if(v.size()==k){
sort(all(v));
bool flag=true;
for(int j=0;j<k;j++){
if(j-1>=0 && v[j].ff<v[j-1].ss)flag=false;
}
if(flag){
for(int j=0;j<n;j++){
if((i & (1<<j))!=0){
cout<<j+1<<"\n";
}
}
return 0;
}
}
}
cout<<-1<<"\n";
}
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... |