Submission #1276994

#TimeUsernameProblemLanguageResultExecution timeMemory
1276994SmuggingSpunEvent Hopping 2 (JOI21_event2)C++20
1 / 100
23 ms1736 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)

event2.cpp: In function 'int main()':
event2.cpp:50:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...