Submission #293599

#TimeUsernameProblemLanguageResultExecution timeMemory
293599DovranMeetings (IOI18_meetings)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "meetings.h"
#define N 100009
#define LL 1000000009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz size
#define pb push_back
#define ll long long

using namespace std;

int n, v[N];
pii t[4*N];
pii T[N*4];

void bld(int nd, int l, int r){
	if(l==r){
		t[nd].ff=v[l];
		t[nd].ss=l;
		return;
	}
	
	int md=(l+r)/2;
	bld(nd*2, l, md);
	bld(nd*2+1, md+1, r);
	
	if(t[nd*2]<=t[nd*2+1])
		t[nd].ss=t[nd*2].ss;
	else
		t[nd].ss=t[nd*2+1].ss;
	
	t[nd].ff=max(t[nd*2].ff, t[nd*2+1].ff);
}

pii tap(int nd, int l, int r, int x, int y){
	if(l>=x and r<=y){
		if(!tp) return t[nd];
		return T[nd];
	}
	if(l>y or r<x){
		if(tp) return {0, 0};
		return {LL, LL};
	}

	int md=(l+r)/2;
	if(tp) return max(tap(nd*2, l, md, x, y, tp), tap(nd*2+1, md+1, r, x, y, tp));
		
	return min(tap(nd*2, l, md, x, y, tp), tap(nd*2+1, md+1, r, x, y, tp));
}

std::vector<ll> minimum_costs(std::vector<int>H, std::vector<int>L, std::vector<int>R){
	n=H.sz();
	for(int i=0; i<n; i++)
		v[i]=H[i];
	bld(1, 0, n-1);
	vector<ll>e;
	for(int i=0; i<(int)L.size(); i++){
		int l=L[i], r=R[i];
		ll ans=0;
		while(r>l){
			int md=(l+r)/2;
			pii p=tap(1, 0, n-1, l, r);
			if(p.ss<md)
				r=md-1;
			else if(p..s>md)
				l=md+1;
			else{
				int a=tap(1, 0, n-1, l, md-1);
				int b=tap(1, 0, n-1, md+1, r);
				if(a>=b)
					l=md+1;
				else
					r=md-1;
			}
			
		}
		for(int j=l; j<=r; j++)
			if(j<=l)
				ans+=tap(1, 0, n-1, j, l).ff;
			else if(j>p.ss)
				ans+=tap(1, 0, n-1, l, j).ff;
		e.pb(ans);
	}
	return e;
}

Compilation message (stderr)

meetings.cpp: In function 'std::pair<int, int> tap(int, int, int, int, int)':
meetings.cpp:39:7: error: 'tp' was not declared in this scope; did you mean 'tap'?
   39 |   if(!tp) return t[nd];
      |       ^~
      |       tap
meetings.cpp:43:6: error: 'tp' was not declared in this scope; did you mean 'tap'?
   43 |   if(tp) return {0, 0};
      |      ^~
      |      tap
meetings.cpp:48:5: error: 'tp' was not declared in this scope; did you mean 'tap'?
   48 |  if(tp) return max(tap(nd*2, l, md, x, y, tp), tap(nd*2+1, md+1, r, x, y, tp));
      |     ^~
      |     tap
meetings.cpp:50:36: error: 'tp' was not declared in this scope; did you mean 'tap'?
   50 |  return min(tap(nd*2, l, md, x, y, tp), tap(nd*2+1, md+1, r, x, y, tp));
      |                                    ^~
      |                                    tap
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:67:14: error: expected unqualified-id before '.' token
   67 |    else if(p..s>md)
      |              ^
meetings.cpp:70:14: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   70 |     int a=tap(1, 0, n-1, l, md-1);
      |           ~~~^~~~~~~~~~~~~~~~~~~~
      |              |
      |              std::pair<int, int>
meetings.cpp:71:14: error: cannot convert 'std::pair<int, int>' to 'int' in initialization
   71 |     int b=tap(1, 0, n-1, md+1, r);
      |           ~~~^~~~~~~~~~~~~~~~~~~~
      |              |
      |              std::pair<int, int>
meetings.cpp:82:14: error: 'p' was not declared in this scope
   82 |    else if(j>p.ss)
      |              ^