QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#646989 | #65. Two Antennas | salmon32 | 0 | 233ms | 85864kb | C++17 | 2.8kb | 2024-10-17 10:46:54 | 2024-10-17 10:46:57 |
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=4e5+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]=val;
st[id]=max(st[id],mx[id]-mn[id]);
push(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
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 48980kb
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 828818552 557668751 746880959 -1 -1 828818552 736480018 828818552 -1 -1 -1 648812417 828818552 828818552 -1 822730718 -1 -...
result:
wrong answer 32nd lines differ - expected: '864679211', found: '746880959'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #49:
score: 22
Accepted
time: 219ms
memory: 83072kb
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:
999974157
result:
ok single line: '999974157'
Test #50:
score: 0
Wrong Answer
time: 233ms
memory: 85864kb
input:
200000 735013405 160382 180860 438296241 78818 157402 24046243 41160 42554 709242874 68247 71171 798805511 35999 117249 804692776 190921 191179 590054369 44526 199082 435774303 154400 189263 529488852 149648 183300 414611064 39654 99464 721973791 41375 122421 478157232 175554 192949 427227260 71502 ...
output:
999918390
result:
wrong answer 1st lines differ - expected: '999989439', found: '999918390'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%