답안 #1086507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086507 2024-09-10T20:47:46 Z EkinOnal 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
//#pragma GCC optimize("O3,unroll-loops,Ofast")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include "wall.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
 
#define MAX 200005
#define pb push_back
#define mp make_pair 
#define int long long
#define f first
#define s second
#define vi vector<int>
#define pii pair<int,int>
#define si set<int>
#define vpii vector<pair<int,int>> 
const int mod = 1e9+7;
const int INF = 1e18;
// myMap.begin()->first :  key
// myMap.begin()->second : value
 
int epow(int a,int b){int ans=1;while(b){if(b&1) ans*=a;a*=a;b>>=1;ans%=mod;a%=mod;}return (ans+mod)%mod;}
int gcd(int a,int b) {if(a<b)swap(a,b);while(b){int tmp=b;b=a%b;a=tmp;}return a;}
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sum(int a,int b){return ((a%mod)+(b%mod))%mod;}

// typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
// typedef 
// tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;

int n,d;
vi arr(MAX);

struct segItem{
	int val,lazymin,lazymax;
};

struct SegTree{
//	segItem tree[MAX*4];
	int mn[MAX],mx[MAX];

	SegTree(){
		memset(mn,-1,sizeof(mn));
		memset(mx,-1,sizeof(mx));
	}

	void push(int v){
		if(mn[v]!=-1){
			if(mn[v*2]==-1) mn[v*2]=mn[v];
			else mn[v*2]=max(mn[v*2],mn[v]);

			if(mn[v*2+1]==-1) mn[v*2+1]=mn[v];
			else mn[v*2+1]=max(mn[v*2+1],mn[v]);

			if(mx[v*2]!=-1) mx[v*2]=max(mx[v*2],mn[v]);
			if(mx[v*2+1]!=-1) mx[v*2+1]=max(mx[v*2+1],mn[v]);

		}
		if(mx[v]!=-1){
			if(mx[v*2]==-1) mx[v*2]=mx[v];
			else mx[v*2]=min(mx[v*2],mx[v]);

			if(mx[v*2+1]==-1) mx[v*2+1]=mx[v];
			else mx[v*2+1]=min(mx[v*2+1],mx[v]);

			if(mn[v*2]!=-1) mn[v*2]=min(mn[v*2],mx[v]);
			if(mn[v*2+1]!=-1) mn[v*2+1]=min(mn[v*2+1],mx[v]);
		}
		mn[v]=mx[v]=-1;
	}

	// void updatemax(int v,int tl,int tr,int l ,int r,int val){
	// 	push(v); 
	// 	if(tl>tr || tl>r || tr<l) return;
	// 	if(tl>=l && tr<=r){
	// 		if(mx[v]==-1) mx[v]=val;
	// 		else mx[v]=min(mx[v],val);
	// 		if(mn[v]!=-1) mn[v]=min(mn[v],val); 
	// 		return;
	// 	}
	// 	int mid=(tl+tr)>>1;
	// 	updatemax(v*2,tl,mid,l,r,val); updatemax(v*2+1,mid+1,tr,l,r,val);
	// }

	void updatemax(int v,int tl,int tr,int l ,int r,int val){
		if(tl>tr || tl>r || tr<l) return;
		if(tl>=l && tr<=r){
			if(mx[v]==-1) mx[v]=val;
			else mx[v]=min(mx[v],val);
			if(mn[v]!=-1) mn[v]=min(mn[v],val); 
			return;
		}
		push(v);
		int mid=(tl+tr)>>1;
		updatemax(v*2,tl,mid,l,r,val); updatemax(v*2+1,mid+1,tr,l,r,val);
	}

	void updatemin(int v,int tl,int tr,int l ,int r,int val){
		if(tl>tr || tl>r || tr<l) return;
		if(tl>=l && tr<=r){
			if(mn[v]==-1) mn[v]=val;
			else mn[v]=max(mn[v],val);
			if(mx[v]!=-1) mx[v]=max(mx[v],val); 
			return;
		}
		push(v); 
		int mid=(tl+tr)>>1;
		updatemin(v*2,tl,mid,l,r,val); updatemin(v*2+1,mid+1,tr,l,r,val);
	}

	void query(int v,int tl,int tr){
		if(tl==tr) {arr[tl]=max(mn[v],0LL);return;}
		int mid=(tl+tr)>>1;
		push(v);
		query(v*2,tl,mid); query(v*2+1,mid+1,tr);
	}

};

SegTree segtree;

void solve(int n,int k,){
	// int n,k; cin>>n>>k;
	// vi op(k+5),left(k+5),right(k+5),height(k+5);
	// for(int i=1;i<=k;i++) cin>>op[i]>>left[i]>>right[i]>>height[i];

	for(int i=1;i<=k;i++){
		if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
		else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
	}
	segtree.query(1,1,n);
	for(int i=1;i<=n;i++) cout<<arr[i]<<endl;

	return;
}

void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    n = N;
 
   for(int i=0;i<k;i++){
		if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
		else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
	}
 
    segtree.query(1,1,n);
    for(int i=1;i<=n;i++) cout<<arr[i]<<endl;
}

Compilation message

wall.cpp:125:24: error: expected identifier before ')' token
  125 | void solve(int n,int k,){
      |                        ^
wall.cpp: In function 'void solve(long long int, long long int, int)':
wall.cpp:131:6: error: 'op' was not declared in this scope; did you mean 'mp'?
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |      ^~
      |      mp
wall.cpp:131:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                              ^
wall.cpp:131:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                        ~~~~~~~^~
wall.cpp:131:57: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                                         ^
wall.cpp:131:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                                  ~~~~~~~~^~
wall.cpp:131:61: error: 'height' was not declared in this scope
  131 |   if(op[i]==1) segtree.updatemin(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                                             ^~~~~~
wall.cpp:132:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  132 |   else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                      ^
wall.cpp:132:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  132 |   else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                ~~~~~~~^~
wall.cpp:132:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  132 |   else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                                 ^
wall.cpp:132:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  132 |   else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                          ~~~~~~~~^~
wall.cpp:132:53: error: 'height' was not declared in this scope
  132 |   else segtree.updatemax(1,1,n,left[i]+1,right[i]+1,height[i]);
      |                                                     ^~~~~~