제출 #813061

#제출 시각아이디문제언어결과실행 시간메모리
813061tolbi휴가 (IOI14_holiday)C++17
컴파일 에러
0 ms0 KiB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X> ostream& operator<<(ostream& os, vector<X> v){for (auto &it : v) os<<it<<" ";return os;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> v){for (auto &it : v) os<<it<<" ";return os;}
ostream& operator<<(ostream& os, bool bl){return os<<(int32_t)bl;}
#define endl '\n'
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for(auto &it : x) cin>>it;
#define coutarr(x) for(auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define tol(bi) (1ll<<((int)(bi)))
typedef long long ll;
const ll INF = LONG_LONG_MAX;
const ll MOD = 1e9+9;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include"holiday.h"
struct SegTree{
	vector<long long> segtree;
	vector<int> say;
	vector<int> pos;
	vector<int> val;
	SegTree(vector<int> arr){
		int n = arr.size();
		segtree.resize(tol(ceil(log2(n)+1))-1,0ll);
		say.resize(segtree.size(), 0ll);
		pos.resize(n);
		val=arr;
		vector<pair<int,int>> hsh(n);
		for (int i = 0; i < n; i++){
			hsh[i]={arr[i],i};
		}
		sortrarr(hsh);
		for (int i = 0; i < n; i++){
			pos[hsh[i].second]=i;
		}
	}
	void activate(int node){
		int vval = val[node];
		node=pos[node];
		node+=segtree.size()/2;
		say[node]=1;
		segtree[node]=vval;
		while (node){
			node=(node-1)/2;
			segtree[node]=segtree[node*2+1]+segtree[node*2+2];
			say[node]=say[node*2+1]+say[node*2+2];
		}
	}
	void deactivate(int node){
		node=pos[node];
		node+=segtree.size()/2;
		segtree[node]=0;
		say[node]=0;
		while (node){
			node=(node-1)/2;
			segtree[node]=segtree[node*2+1]+segtree[node*2+2];
			say[node]=say[node*2+1]+say[node*2+2];
		}
	}
	long long query(int x){
		if (x<0) x = 0;
		if (x>say[0]) x = say[0];
		if (!x) return 0;
		int node = 0;
		long long rval = 0ll;
		while (node*2+1<segtree.size()){
			if (say[node*2+1]>=x){
				node=node*2+1;
			}
			else {
				rval+=segtree[node*2+1];
				x-=say[node*2+1];
				node=node*2+2;
			}
		}
		rval+=segtree[node];
		return rval;
	}
};
pair<vector<int>,vector<ll>> f(vector<int> attraction){
	int n = attraction.size();
	vector<int> res(n*2);
	vector<ll> val(n*2,-1);
	if (n==0){
		return {res,val};
	}
	SegTree segtree(attraction);
	function<void(int,int,int)> calc; 
	calc = [&](int x, int l, int r){
		for (int i = l; i <= r; i++){
			segtree.activate(i);
			int j = x-i;
			long long crr = segtree.query(j);
			if (crr>val[x]){
				val[x]=crr;
				res[x]=i;
			}
		}
		for (int i = l; i <= r; i++){
			segtree.deactivate(i);
		}
	};
	function<void(int,int,int,int)> f;
	f = [&](int l, int r, int tl, int tr)->void{
		if (l>r) return;
		int mid = l+(r-l)/2;
		calc(mid,tl,tr);
		int pos = res[mid];
		f(l,mid-1,tl,pos);
		for (int i = tl; i < pos; i++){
			segtree.activate(i);
		}
		f(mid+1,r,pos,tr);
		for (int i = tl; i < pos; i++){
			segtree.deactivate(i);
		}
	};
	f(0,res.size()-1,0,n-1);
	return {res,val};
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
	bool tekrar = true;
	if (attraction[0]<0) attraction[0]*=-1,tekrar=false;
	vector<int> _left, _right;
	for (int i = start; i >= 0; i--){
		_left.push_back(attraction[i]);
	}
	for (int i = start+1; i < n; i++){
		_right.push_back(attraction[i]);
	}
	auto [left, valleft] = f(_left);
	auto [right, valright] = f(_right);
	ll ans = 0;
	if (right.size()==0){
		return valleft[min(d,valleft.size()-1)];
	}
	for (int i = 0; i < min(d+1,(int)left.size()); i++){
		int pos = left[i];
		int kalan = d-i-pos-1;
		if (kalan<0 || valright.size()==0) {ans=max(ans,valleft[i]);continue;}
		ans=max(ans,valleft[i]+valright[min(kalan,(int)valright.size()-1)]);
	}
	if (tekrar){
		for (int i = 0; i < n-i-1; i++){
			swap(attraction[i],attraction[n-i-1]);
		}
		attraction[0]*=-1;
		ans=max(ans,findMaxAttraction(n, n-start-1, d, attraction));
	}
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
holiday.cpp: In member function 'long long int SegTree::query(int)':
holiday.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |   while (node*2+1<segtree.size()){
      |          ~~~~~~~~^~~~~~~~~~~~~~~
holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:150:40: error: no matching function for call to 'min(int&, std::vector<long long int>::size_type)'
  150 |   return valleft[min(d,valleft.size()-1)];
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:12:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
holiday.cpp:150:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
  150 |   return valleft[min(d,valleft.size()-1)];
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from holiday.cpp:12:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
holiday.cpp:150:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
  150 |   return valleft[min(d,valleft.size()-1)];
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:12:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
holiday.cpp:150:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  150 |   return valleft[min(d,valleft.size()-1)];
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:12:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
holiday.cpp:150:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  150 |   return valleft[min(d,valleft.size()-1)];
      |                                        ^