답안 #1044753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044753 2024-08-05T13:15:20 Z vjudge1 가로등 (APIO19_street_lamps) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using std::cin, std::cout, std::vector, std::set, std::endl, std::string, std::map,std::pair,std::queue, std::max, std::min;

#ifdef LOCAL
#define file freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#else
#define file ;;
#endif

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template <typename T>
using Tree = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#include <random>

class segt{
private:
	int n;
	vector<int> tree;
	int build(int node, int l, int r, vector<int>& a){
		if(l==r){
			return tree[node] = a[l-1];
		}
		int mid = (l+r)/2;
		return tree[node]=max(build(node*2, l, mid, a), build(node*2+1, mid+1, r, a));
	}

	void build(int n, vector<int> a){
		build(1, 1, n, a);
	}

	int update(int node, int l, int r, int x, int b){
		if(l==r){
			return tree[node]=b;
		}
		int mid = (l+r)/2;
		if(mid>=x) update(node*2,l,mid,x, b);
		else update(node*2+1,mid+1,r,x, b);
		return tree[node] = max(tree[node*2],tree[node*2+1]);
	}

	int query(int node, int l, int r, int x, int y){
		if(l>=x && r<=y){
			return tree[node];
		}
		int mid = (l+r)/2;
		if(mid<x) return query(node*2+1, mid+1, r, x, y);
		else if(mid>=y) return query(node*2, l, mid, x, y);
		return max(query(node*2,l,mid,x,y),query(node*2+1,mid+1,r,x,y));
	}

public:
	segt(vector<int> a){
		n = a.size();
		tree.resize(4*n+5);
		cp;
		build(n,a);
		cp;
	}

	void update(int x, int b){
		update(1,1,n,x,b);
	}

	int query(int l, int r){
		return query(1,1,n,l,r);
	}
};

int main(){
	file;
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>a(n);
	for(int i=0;i<n;i++) a[i]=(s[i] == '1' ? 0:q+5);
	cp;
	segt ss(a);
	cp;
	vector<vector<int>> hist(n+1,vector<int>(1,0));
	for(int i=1;i<=q;i++){
		string ty;
		cin >> ty;
		if(ty[0]=='q'){
			int a,b;
			cin >> a >> b;
			cout << max(0,i-ss.query(a,b)) << endl;
		}
		else if(ty[0]=='t'){
			int a;
			cin >> a;
			ss.update(a,i);
		}

	}
	return 0;
}

Compilation message

street_lamps.cpp: In constructor 'segt::segt(std::vector<int>)':
street_lamps.cpp:58:3: error: 'cp' was not declared in this scope
   58 |   cp;
      |   ^~
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:80:2: error: 'cp' was not declared in this scope
   80 |  cp;
      |  ^~