답안 #744049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744049 2023-05-18T07:41:36 Z salmon Weirdtree (RMI21_weirdtree) C++14
컴파일 오류
0 ms 0 KB
#include "weirdtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> lst;
priority_queue<int> pq;

void initialise(int N, int Q, int h[]) {
	lst.push_back(0);
	for(int i = 1; i <= N; i++){
		lst.push_back(h[i]);
	}
}

void cut(int l, int r, int k) {
	for(int i = l; i <= r; i++){
        pq.push(make_pair(v[i],-i));
	}

	while(k != 0)
        if(pq.top() == 0){
            return;
        }
    }

    v[-pq.top().second]--;

	pq.clear();
}
void magic(int i, int x) {
	v[i] = x;
}
long long int inspect(int l, int r) {
	long long int V = 0;

	for(int i = l ; i <= r; i++){
        V = V + lst[i];
	}

	return V;
}

Compilation message

weirdtree.cpp: In function 'void cut(int, int, int)':
weirdtree.cpp:16:27: error: 'v' was not declared in this scope
   16 |         pq.push(make_pair(v[i],-i));
      |                           ^
weirdtree.cpp: At global scope:
weirdtree.cpp:25:5: error: 'v' does not name a type
   25 |     v[-pq.top().second]--;
      |     ^
weirdtree.cpp:27:2: error: 'pq' does not name a type
   27 |  pq.clear();
      |  ^~
weirdtree.cpp:28:1: error: expected declaration before '}' token
   28 | }
      | ^
weirdtree.cpp: In function 'void magic(int, int)':
weirdtree.cpp:30:2: error: 'v' was not declared in this scope
   30 |  v[i] = x;
      |  ^