QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#185643#3101. Event Hopping 2sjc061031#Compile Error//C++142.3kb2023-09-22 13:50:562024-07-04 02:06:59

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:06:59]
  • 评测
  • [2023-09-22 13:50:56]
  • 提交

answer

#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n,k,l[100010],r[100010],nxt[200010][20];
vector<int> v[200010];
set<pair<int,int> > s;

inline int calc(int x,int y)
{
	int tot=0;
	for(int i=20-1;i>=0;i--) if(nxt[x][i]<=y){
		x=nxt[x][i];tot+=(1<<i);
	}
	return tot;
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>l[i]>>r[i];
	vector<int> vec;
	for(int i=1;i<=n;i++) vec.push_back(l[i]),vec.push_back(r[i]);
	sort(vec.begin(),vec.end());vec.erase(unique(vec.begin(),vec.end()),vec.end());
	int cnt=(int)vec.size();
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(vec.begin(),vec.end(),l[i])-vec.begin()+1;
		r[i]=lower_bound(vec.begin(),vec.end(),r[i])-vec.begin()+1;
		v[l[i]].push_back(r[i]);
	}
	int minv=cnt+1;
	for(int i=cnt+1;i>=0;i--){
		for(int j=0;j<(int)v[i].size();j++) minv=min(minv,v[i][j]);
		nxt[i][0]=minv;
	}
	for(int i=1;i<20;i++){
		for(int j=0;j<=cnt+1;j++){
			nxt[j][i]=nxt[nxt[j][i-1]][i-1];
		}
	}
	int now=0,res=calc(0,cnt);
	if(res<k){
		cout<<-1<<'\n';
		return 0;
	}
	vector<int> ans;
	s.insert(make_pair(0,0));s.insert(make_pair(cnt,cnt));
	set<pair<int,int> >::iterator it;
	for(int i=1;i<=n&&now<k;i++){
		pair<int,int> x=make_pair(l[i],r[i]);
		it=s.lower_bound(x);
		pair<int,int> nxt=(*it);it--;
		pair<int,int> pre=(*it);
		if(!(pre.second<=x.first&&x.second<=nxt.first)) continue;
		int nw=now+1+res;
		nw-=calc(pre.second,nxt.first);
		nw+=calc(pre.second,x.first);nw+=calc(x.second,nxt.first);
		if(nw<k) continue;
		now++;res=nw-now;ans.push_back(i);
		s.insert(x);
	}
	for(int i=0;i<(int)ans.size();i++){
		cout<<ans[i]<<'\n';
	}
	return 0;
}

Details

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~