QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#646978 | #65. Two Antennas | salmon32 | 0 | 0ms | 31244kb | C++17 | 2.8kb | 2024-10-17 10:42:38 | 2024-10-17 10:42:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define all(x) x.begin(),x.end()
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll maxn=2e5+69;
const ll offset=2e5;
const ll inf=1e18;
const int base=350;
const ll mod=1e9+7;
int n,mn[maxn*4],mx[maxn*4],st[maxn*4],a[maxn],b[maxn],h[maxn],l[maxn],r[maxn],ans[maxn];
vector<int> in[maxn],out[maxn],qr[maxn];
void push(int id)
{
mn[id*2]=min(mn[id],mn[id*2]);
st[id*2]=max(st[id*2],mx[id*2]-mn[id*2]);
mn[id*2+1]=min(mn[id],mn[id*2+1]);
st[id*2+1]=max(st[id*2+1],mx[id*2+1]-mn[id*2+1]);
mn[id]=inf;
}
void Update(int u,int v,int id=1,int l=1,int r=n)
{
if (l==r)
{
mx[id]=v;
return;
}
push(id);
int mid=l+r>>1;
if (u<=mid) Update(u,v,id*2,l,mid);
else Update(u,v,id*2+1,mid+1,r);
mx[id]=max(mx[id*2],mx[id*2+1]);
}
void Update_real(int u,int v,int val,int id=1,int l=1,int r=n)
{
if (u>r || v<l) return;
if (u<= l && r<=v)
{
mn[id]=min(mn[id],val);
st[id]=max(st[id],mx[id]-mn[id]);
return;
}
int mid=l+r>>1;
push(id);
Update_real(u,v,val,id*2,l,mid);
Update_real(u,v,val,id*2+1,mid+1,r);
st[id]=max(st[id*2],st[id*2+1]);
}
int Get(int u,int v,int id=1,int l=1,int r=n)
{
if (u>r || v<l) return -inf;
if (u<=l && r<=v) return st[id];
push(id);
int mid=l+r>>1;
return max(Get(u,v,id*2,l,mid),Get(u,v,id*2+1,mid+1,r));
}
void solve()
{
for1(i,1,n*4) mx[i]=st[i]=-1,mn[i]=inf;
for1(i,1,n)
{
in[i+a[i]].pb(i);
out[i+b[i]].pb(i);
for(int j:in[i])
{
Update(j,h[j]);
// cerr<<"cdc "<<i<<' '<< j<<' '<<h[j]<<'\n';
}
// if (i==3) cerr<< i-b[i]<<' '<<i-a[i]<<'\n';
Update_real(i-b[i],i-a[i],h[i]);
for(int j:qr[i]) ans[j]=max(ans[j],Get(l[j],r[j]));
for(int j:out[i]) Update(j,-1);
in[i].clear();
out[i].clear();
}
}
void sol()
{
cin >> n;
for1(i,1,n)
{
cin >> h[i]>> a[i]>> b[i];
}
int q; cin >> q;
for1(i,1,q)
{
cin >> l[i]>> r[i];
qr[r[i]].pb(i);
ans[i]=-1;
}
solve();
for1(i,1,n) h[i]=1e9-h[i];
solve();
for1(i,1,q) cout << ans[i]<<'\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("990G.inp","r",stdin);
// freopen("990G.out","w",stdout);
int t=1;//cin >> t;
for1(i,1,t) {
// cout << "Case #"<<i<<": ";
sol();
}
}
/*
3
10 2 4
2 1 1
1 1 3
1
2 3
*/
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 31244kb
input:
111 2342163 25 76 738276997 50 52 1669890 26 40 14902411 56 81 899007094 32 85 422634516 2 71 936109680 79 100 638713463 109 110 119468142 28 104 713258492 104 107 267306336 1 39 973810399 87 90 835929417 43 86 335127775 12 104 840490095 39 66 459253103 11 104 706538155 4 101 194912428 82 96 9492220...
output:
-1 -1 828818552 -1 -1 958376243 -1 736480018 -1 -1 -1 828818552 648812417 648812417 -1 -1 736480018 -1 -1 -1 828818552 -1 828818552 828818552 609416339 350445999 828818552 -1 -1 847676935 557668751 864679211 -1 -1 828818552 736480018 828818552 -1 -1 -1 648812417 828818552 828818552 -1 822730718 -1 -...
result:
wrong answer 30th lines differ - expected: '828818552', found: '847676935'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Runtime Error
Test #49:
score: 0
Runtime Error
input:
179825 2342163 108549 159456 738276997 86996 90187 1669890 80080 105339 14902411 174494 177180 899007094 135456 178826 422634516 81580 147876 936109680 77457 155526 638713463 81787 150676 119468142 164826 167174 713258492 52936 91838 267306336 157071 162761 973810399 10675 157410 835929417 149623 17...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%