QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#505306#1140. Distributing CandiesDan4LifeCompile Error//C++231.5kb2024-08-05 01:33:452024-08-05 01:33:45

Judging History

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

  • [2024-08-05 01:33:45]
  • 评测
  • [2024-08-05 01:33:45]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using vi = vector<int>;
using ll = long long;
const int mxN = (int)2e5+10;
const int INF = (int)1e9+1;
const ll LINF = (ll)1e18;
ll mxsuf[mxN], mnsuf[mxN], pref[mxN];

vi distribute_candies(vi c, vi l, vi r, vi v){
    int n = sz(c), q = sz(l); vector<ll> ans(n,0);
    l.insert(begin(l),0), l.insert(begin(l),0);
    r.insert(begin(r),n-1); r.insert(begin(r),n-1);
    v.insert(begin(v),-INF); v.insert(begin(v),INF); q+=2;
    if(*max_element(all(l))==0 and *min_element(all(r))==n-1){
		mxsuf[q]=-LINF; mnsuf[q]=LINF; pref[0]=0;
		for(int i = 0; i < q; i++) pref[i]=(i?pref[i-1]:0)+v[i];
		for(int i = q-1; i >= 0; i--) mxsuf[i]=max(mxsuf[i+1],pref[i]);
		for(int i = q-1; i >= 0; i--) mnsuf[i]=min(mnsuf[i+1],pref[i]);
		for(int i = 0; i < n; i++){
			int k = 0;
			for(int j = 0; j < q; j++){
				ans[i]+=v[j];
				if(ans[i]<=0) ans[i]=0,k=-(j+1);
				if(ans[i]>=c[i]) ans[i]=c[i],k=(j+1);
			}
			ans[i] = 0;
			if(mxsuf[0]-mnsuf[0] < c[i]){
				ans[i]+=pref[q]; continue;
			}
			int L = 0, R = q-1;
			while(L<R){
				int mid = (L+R)/2;
				if(mxsuf[mid]-mnsuf[mid] >= c[i]) L=mid+1;
				else R=mid;
			}
			if(v[L]>0) ans[i]=c[i];
			ans[i]+=pref[q-1]-pref[L];
		}
	}
	vi Ans; Ans.clear();
	for(auto u : ans) Ans.pb(u);
    return Ans;
}

Details

In file included from /usr/include/c++/13/vector:63,
                 from candies.h:1,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr 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’ ‘constexpr 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:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~