제출 #293442

#제출 시각아이디문제언어결과실행 시간메모리
293442Dovran모임들 (IOI18_meetings)C++11
컴파일 에러
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].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=min(t[nd*2].ff, t[nd*2+1].ff);
	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, int tp){
	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));
}

vector<int> minimum_costs(vector<int>H, vector<int>L, vector<int>R){
	n=v.sz();
	for(int i=0; i<n; i++)
		v[i]=h[i];
	bld(1, 0, n-1);
	vector<int>e;
	for(int i=0; i<L.sz(); i++){
		int l=L[i], r=R[i];
		int ans=0;
		pii p=tap(1, 0, n-1, l, r, 0);
		for(int j=l; j<=r+1; j++)
			if(j<p.ss)
				ans+=tap(1, 0, n-1, j, p.ss-1, 1).ff;
			else if(j>p.ss)
				ans+=tap(1, 0, n-1, p.ss+1, j, 1).ff;
		e.pb(ans);
	}
	return e;
}

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

meetings.cpp:55:13: error: ambiguating new declaration of 'std::vector<int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)'
   55 | vector<int> minimum_costs(vector<int>H, vector<int>L, vector<int>R){
      |             ^~~~~~~~~~~~~
In file included from meetings.cpp:2:
meetings.h:5:24: note: old declaration 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)'
    5 | std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
      |                        ^~~~~~~~~~~~~
meetings.cpp: In function 'std::vector<int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:8:12: error: request for member 'size' in 'v', which is of non-class type 'int [100009]'
    8 | #define sz size
      |            ^~~~
meetings.cpp:56:6: note: in expansion of macro 'sz'
   56 |  n=v.sz();
      |      ^~
meetings.cpp:58:8: error: 'h' was not declared in this scope
   58 |   v[i]=h[i];
      |        ^
meetings.cpp:61:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  for(int i=0; i<L.sz(); i++){
      |               ~^~~~~~~