QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666468 | #4077. 뚫기 | masterhuang | 0 | 86ms | 14064kb | C++23 | 2.0kb | 2024-10-22 18:38:46 | 2024-10-22 18:38:49 |
Judging History
answer
#include "breakthru.h"
#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[wz];P <1=::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;}
void init(int _n,int _m,vector<int>Y1,vector<int>Y2)
{
n=_n,m=_m;basic_string<int>g;g+=0,g+=m;V=m;
for(int i=1;i<=n;i++) l[i]=Y1[i-1],r[i]=Y2[i-1],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());
}
LL minimize(int A,int 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;
return MUL(T[l],t);
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
6 2 1 1 1 0 1 0 0 0 1 1 1 0 1 724642704 32998300
output:
Unauthorized output
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #60:
score: 19
Accepted
time: 81ms
memory: 14020kb
input:
500 10 1000000 2 9 2 7 3 6 1 6 3 5 0 5 3 4 6 8 4 8 1 6 1 5 6 7 7 7 6 9 0 7 4 5 0 6 0 2 4 6 0 6 1 7 2 8 0 9 0 9 0 9 0 7 3 6 8 8 2 4 4 4 0 5 2 5 1 6 0 9 2 7 0 8 9 9 1 4 0 9 2 4 1 9 2 8 2 6 0 4 5 9 4 5 3 9 2 6 1 9 0 6 6 8 2 9 4 9 7 9 2 7 1 5 1 8 0 6 0 9 2 9 3 9 0 2 4 4 5 9 4 7 8 9 4 9 1 8 3 8 2 9 6 6 3...
output:
109125435050 79679504214 40397444309 33486843995 50549382350 8831039674 29373662236 35916635082 1627822212 83193326242 7021463069 18347246004 17908310304 40111838606 42807634739 83808922569 36682521996 87471336298 56912099994 74488880562 59044328919 71779759293 47086282044 46402519236 10235901992 55...
result:
ok 1000000 lines
Test #61:
score: 19
Accepted
time: 84ms
memory: 11848kb
input:
500 10 1000000 2 3 0 5 4 8 5 9 1 3 3 8 0 1 3 8 2 8 2 9 1 3 3 3 1 8 5 9 3 9 4 5 6 9 2 9 2 3 0 8 2 9 0 3 1 9 9 9 2 9 2 7 2 8 2 4 6 9 2 9 0 9 2 8 2 8 0 4 2 6 7 8 0 9 0 8 0 9 2 7 5 7 4 7 0 9 5 6 0 4 2 7 0 7 2 9 2 8 0 2 1 6 0 9 1 6 0 7 7 9 0 8 4 9 1 5 0 9 1 7 0 2 4 8 2 2 5 5 4 8 3 7 8 8 1 5 9 9 0 8 4 4 0...
output:
93932220045 43423248548 63878537436 19958848316 34458591915 74471642637 29392721565 108979131384 68348696934 50344204576 86393681343 95187505608 59870044263 83702649696 40342598040 43679949188 38834691528 68528731476 73704081803 21220971702 17051904446 74680125785 33411395765 34066852792 84600145110...
result:
ok 1000000 lines
Test #62:
score: 0
Wrong Answer
time: 86ms
memory: 14064kb
input:
500 10 1000000 0 9 0 9 1 9 1 9 2 9 0 8 5 7 0 8 6 9 0 5 3 6 1 8 4 8 0 6 1 3 3 3 3 7 0 9 2 3 6 7 0 4 3 9 2 8 7 9 4 5 6 9 8 9 2 6 5 8 5 7 1 1 0 5 0 9 0 1 4 8 0 9 3 8 2 9 3 8 0 8 5 8 0 9 0 8 2 5 0 9 5 8 5 9 2 3 6 8 0 6 2 4 5 7 5 8 2 9 0 7 1 8 0 9 6 8 3 7 0 5 0 7 3 5 1 8 2 8 0 8 7 9 7 9 2 2 0 9 1 8 5 5 5...
output:
57026961526 17848690951 99635443948 24983590233 44471894109 48040845836 78801683211 92617033538 95131564360 76003932078 4710856179 104824016509 83455743908 78148882789 31398746199 56921062405 8610055861 12034412595 76850763508 52731113665 57708287054 70697847727 42403292275 24664520532 110883680880 ...
result:
wrong answer 11th lines differ - expected: '4524951945', found: '4710856179'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%