제출 #543483

#제출 시각아이디문제언어결과실행 시간메모리
543483fuad27Connecting Supertrees (IOI20_supertrees)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
#define ff first
#define ss second
ll fen[N];
ll arr[N];
void upd(int at, ll val) {
	at++;
	while(at < N) {
		fen[at] = max(fen[at], val);
		at+=at&(-at);
	}
}
ll get(int r) {
	r++;
	ll mx = 0;
	while(r > 0) {
		mx = max(mx, fen[r]);
		r-=r&(-r);
	}
	return mx;
}
int main () {
	int n, m;
	cin >> n >> m;
	for(int i = 0;i<N;i++)fen[i] = 0;
	for(int i = 0;i<n;i++)cin >> arr[i];
	vector<pair<pair<ll,ll>, ll>> que[n];
	for(int i = 0;i<m;i++){
		ll l, r, v;
		cin >> l >> r >> v;
		que[i].push_back(make_pair(make_pair(r, v), i));
	}
	ll ans[m];
	vector<ll> stk;
	for(int i = n-1;i>=0;i--) {
		while(stk.size() and arr[stk.back()]>=arr[i])stk.pop_back();
		if(stk.size())upd(stk.back(), arr[stk.back()]+arr[i]);
		stk.push_back(i);
		for(auto q:que[i]) {
			ans[q.ss] = get(q.ff.ff);
		}
	}
	for(int i = 0;i<m;i++) {
		cout << ans[i] << "\n";
	}
}

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

/usr/bin/ld: /tmp/ccmaQdW8.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3Cbwp9.o:supertrees.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccmaQdW8.o: in function `main':
grader.cpp:(.text.startup+0x39a): undefined reference to `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status