Submission #893358

#TimeUsernameProblemLanguageResultExecution timeMemory
893358vjudge1Event Hopping 2 (JOI21_event2)C++17
0 / 100
25 ms6960 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl "\n" #define ll long long #define int ll int E,B; void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll N=5e5+5,INF=1e18,mod=1e9+7; void solve(){ int n,k;cin>>n>>k; vector<pair<pair<int,int>,int>> vec; for(int i=0;i<n;i++){ int a,b;cin>>a>>b;vec.pb({{b,a},i}); } sort(all(vec)); int cur=0,ans=0; vector<int> res; for(auto it: vec){ if(it.fr.sc>=cur){ cur=it.fr.fr; res.pb(it.sc); ans++; } } if(k>(int)res.size()) cout<<-1; else{ sort(all(res)); for(int i=0;i<k;i++) cout<<res[i]+1<<endl; } //cout<<ans; } main(){ B=clock(); ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } E=clock(); cerr<<"\n\n\n\nTIME: "<<((float)E-B)/CLOCKS_PER_SEC<<" SECONDS"; }

Compilation message (stderr)

event2.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main(){
      | ^~~~
event2.cpp: In function 'void fopn(std::string)':
event2.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen((name+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
event2.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((name+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...