QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#666429#4077. 뚫기masterhuangCompile Error//C++202.0kb2024-10-22 18:26:042024-10-22 18:26:12

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 18:26:12]
  • 评测
  • [2024-10-22 18:26:04]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define P pair<LL,LL>
#define fi first
#define se second
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=1e4+5,M=N<<3;const LL inf=1e17;
int n,m,V,q,l[N],r[N];LL lt[M];P a[M],lt1[M];
vector<P>T;
inline int mul(P A,P B,P C){return (B.fi-A.fi)*(C.se-A.se)-(C.fi-A.fi)*(B.se-A.se);}
inline void pushup(int wz){a[wz]=min(a[wz<<1],a[wz<<1|1]);}
inline void upd(int wz,LL x){a[wz].fi+=x,lt[wz]+=x,lt1[wz].fi+=x;}
inline void upd1(int wz,P x){a[wz]=min(a[wz],x);lt1[wz]=min(lt1[wz],x);}
inline void pushdown(int wz)
{
	LL &lt=::lt[wz];P &lt1=::lt1[wz];
	if(lt) upd(wz<<1,lt),upd(wz<<1|1,lt),lt=0;
	if(lt1.fi!=inf) upd1(wz<<1,lt1),upd1(wz<<1|1,lt1),lt1={inf,inf};
}
void updata(int l,int r,int wz,int L,int R,LL x)
{
	if(L<=l&&r<=R) return upd(wz,x);
	int mid=(l+r)>>1;pushdown(wz);
	if(L<=mid) updata(l,mid,wz<<1,L,R,x);
	if(mid<R) updata(mid+1,r,wz<<1|1,L,R,x);
	pushup(wz);
}
inline P sol(int A,int B)
{
	for(int i=1;i<=(m<<2);i++) lt[i]=0,a[i]=lt1[i]={0,0};
	for(int i=1;i<=n;i++)
	{
		updata(1,m,1,l[i],r[i],B);P t=a[1];
		upd1(1,{t.fi+A,t.se+1});
	}auto [u,v]=a[1];
	return {v,(u-v*A)/B};
}
void dfs(P A,P B)
{
	P C=sol(A.se-B.se,B.fi-A.fi);
	if(mul(A,B,C)<0) T.push_back(C),dfs(A,C),dfs(C,B);
}
inline LL MUL(P A,P B){return A.fi*B.fi+A.se*B.se;}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>n>>m>>q;
	basic_string<int>g;g+=0,g+=m;V=m;
    for(int i=1;i<=n;i++) cin>>l[i]>>r[i],g+=l[i],g+=r[i]+1;
	sort(g.begin(),g.end());g.erase(unique(g.begin(),g.end()),g.end());
	for(int i=1;i<=n;i++) l[i]=lower_bound(g.begin(),g.end(),l[i])-g.begin()+1,
	r[i]=upper_bound(g.begin(),g.end(),r[i])-g.begin();m=g.size()-1;
	P A=sol(V,1),B=sol(1,V);T.push_back(A),T.push_back(B);dfs(A,B);
	sort(T.begin(),T.end());
	for(int A,B;q--;)
	{
		cin>>A>>B;P t={A,B};
		int l=0,r=T.size()-1,mid;
		while(l<r) mid=(l+r)>>1,(MUL(T[mid],t)<MUL(T[mid+1],t))?r=mid:l=mid+1;
		cout<<MUL(T[l],t)<<"\n";
	}
    return 0;
}

詳細信息

/usr/bin/ld: /tmp/ccOBTqDH.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccRHW9lG.o:implementer.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccRHW9lG.o: in function `main':
implementer.cpp:(.text.startup+0x1fc): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: implementer.cpp:(.text.startup+0x25f): undefined reference to `minimize(int, int)'
collect2: error: ld returned 1 exit status