# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1276994 | SmuggingSpun | Event Hopping 2 (JOI21_event2) | C++20 | 23 ms | 1736 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
const int lim = 1e5 + 5;
int n, k, l[lim], r[lim];
namespace sub2{
void solve(){
vector<int>p, best;
for(int mask = (1 << n) - 1; mask > 0; mask--){
if(__builtin_popcount(mask) == k){
p.clear();
for(int i = 0; i < n; i++){
if(mask >> i & 1){
p.push_back(i + 1);
}
}
sort(p.begin(), p.end(), [&] (int i, int j){
return l[i] < l[j];
});
for(int i = 1; i < k; i++){
if(l[p[i]] < r[p[i - 1]]){
p.clear();
break;
}
}
if(!p.empty()){
sort(p.begin(), p.end());
if(best.empty() || p < best){
swap(best, p);
}
}
}
}
if(best.empty()){
return void(cout << "-1\n");
}
for(int& x : best){
cout << x << "\n";
}
}
}
namespace sub134{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> l[i] >> r[i];
}
if(n <= 20){
sub2::solve();
}
else{
sub134::solve();
}
}
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... |