Submission #810976

# Submission time Handle Problem Language Result Execution time Memory
810976 2023-08-06T18:48:46 Z arashMLG Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#endif
using namespace std;

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

//https://quera.org/profile/4dykhk

typedef long long     ll;
typedef long double   ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;

const int N =2e6 + 23;
const ll mod = 1e9+7; // 998244353
const int LOG = 23;
const ll inf = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define F           first
#define S           second
#define pb          push_back
#define ms(x,y)     memset((x) , (y) , sizeof (x))
#define done        return cout<<endl , 0;
#define kill(x)     cout<<x<<endl, exit(0);
#define isIn(x,s,e) ((x) >= (s) && (x) <= e)
#define all(x)      x.begin(),x.end()
#define sz(x)       (int)x.size()
#define pc(x)       __builtin_popcount(x)
#define ctz(x)      __builtin_ctz(x)
#define MinHeap(x)  priority_queue<x, vector<x> , greater<x> >
#define MaxHeap(x)  priority_queue<x, vector<x>>
#define lc          (v << 1)
#define rc          ((v<<1) |1)
//#define int      ll

ll pw(ll a, ll b, ll md = mod){ll res = 1; while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int ans[N];
pii t[N<<2];

void upd(int v,int l,int r,int x,int op,int tl,int tr) {
	if(l > r) return;
	x = max(x,t[v].F);
	x= min(x,t[v].S);
	if(l == tl && r == tr-1) {
		 if(op)
		 	t[v].S = x;
		 else
		 	t[v].F = x;
		 return;
	}
	
	int mid=(tl+tr)/2;
	
	upd(lc,l,min(mid-1,r),x,op,tl,mid);
	upd(rc,max(l,mid),r,x,op,mid,tr);
}


void make(int v,int x,int tl,int tr) {
	x = max(x,t[v].F);
	x = min(x,t[v].S);
	if(tr- tl == 1) {
		ans[tl] = x;
		return;
	}
	int mid=(tl+tr)/2;
	
	make(lc,x,tl,mid);
	make(rc,x,mid,tr);
}


void buildWall(int n, int k, int op[], int left[], int right[], int h[], int finalHeight[]){
	fill(t,t+(N<<2),{0,mod});
	for(int i = 0 ; i< k ; i++) upd(1,left[i],right[i],h[i],op[i],0,n);
	make(1,0,0,n);
	for(int i = 0 ; i< n ; i++) finalHeight[i] = ans[i];
	return;
}

Compilation message

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:83:25: error: no matching function for call to 'fill(pii [8000092], pii*, <brace-enclosed initializer list>)'
   83 |  fill(t,t+(N<<2),{0,mod});
      |                         ^
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 wall.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:937:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
  937 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/10/bits/stl_algobase.h:937:5: note:   template argument deduction/substitution failed:
wall.cpp:83:25: note:   couldn't deduce template parameter '_Tp'
   83 |  fill(t,t+(N<<2),{0,mod});
      |                         ^
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_bvector.h:434:3: note: candidate: 'void std::fill(std::_Bit_iterator, std::_Bit_iterator, const bool&)'
  434 |   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
      |   ^~~~
/usr/include/c++/10/bits/stl_bvector.h:434:22: note:   no known conversion for argument 1 from 'pii [8000092]' {aka 'std::pair<int, int> [8000092]'} to 'std::_Bit_iterator'
  434 |   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
      |        ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note:   template argument deduction/substitution failed:
wall.cpp:83:25: note:   candidate expects 4 arguments, 3 provided
   83 |  fill(t,t+(N<<2),{0,mod});
      |                         ^