QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54961 | #4236. Triangular Logs | KING_UT# | TL | 2ms | 3720kb | C++20 | 2.0kb | 2022-10-11 19:02:29 | 2022-10-11 19:02:35 |
Judging History
answer
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loos")
#endif
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
template<class t>using vc=vector<t>;
template<class t>using vvc=vc<vc<t>>;
template<class t, class u>bool chmin(t &a, u b){
if(a > b){ a = b; return true;}
else return false;
}
template<class t, class u>bool chmax(t &a, u b){
if(a < b){ a = b; return true;}
else return false;
}
using vi=vc<int>;
#define a first
#define b second
#define mp make_pair
using pi=pair<int,int>;
const int inf=INT_MAX/2-100;
template<class t> int lwb(const vc<t>&vs,t v){
return lower_bound(all(vs),v)-vs.bg;
}
const int K=128;
const int nmax=1024;
int ss[K],bucket[K][nmax];
void slv(){
int n,q;cin>>n>>q;
vi xs(n),ys(n),hs(n);
vc<pi> ls(n);
rep(i,n){
int x,y,h;cin>>x>>y>>h;
xs[i]=x;
ys[i]=y;
hs[i]=h;
ls[i]=pi(x,i);
}
sort(all(ls));
vi a(n),b(n);
rep(i,n){
auto [x,j]=ls[i];
//yh[i]=pi(ys[j],hs[j]);
a[i]=ys[j];
b[i]=hs[j];
}
const int L=100;
vi buf;
rep(_,q){
buf.clear();
int xl,yl,xr,yr;
cin>>xl>>yl>>xr>>yr;
xl=lwb(ls,pi(xl,-inf));
xr=lwb(ls,pi(xr,+inf));
int l=(xl+K-1)/K;
int r=xr/K;
auto upd=[&](int p){
if(si(buf)>=L)return false;
if(yl<=a[p]&&a[p]<=yr)buf.pb(b[p]);
return true;
};
if(l<=r){
rng(j,l,r){
rep(k,K){
int p=j*K+k;
bucket[k][ss[k]]=b[p];
ss[k]+=(yl<=a[p]&&a[p]<=yr);
}
}
rng(p,xl,l*K)if(!upd(p))break;
rng(p,r*K,xr)if(!upd(p))break;
rep(k,K)rep(j,ss[k])if(!upd(bucket[k][j]))break;
}else{
rng(p,xl,xr)if(!upd(p))break;
}
bool ok=false;
sort(all(buf));
rep(i,si(buf)-2){
if(buf[i]+buf[i+1]>buf[i+2])ok=true;
}
cout<<ok<<"\n";
}
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
slv();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3720kb
input:
9 5 1 3 3 2 3 1 3 3 4 1 2 1 2 2 5 3 2 9 1 1 2 2 1 6 3 1 5 1 1 1 2 1 1 2 2 1 1 1 3 1 2 3 2 1 1 3 3
output:
0 1 0 0 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
481 1 8 6788 8975 24 6552 2668 26 7948 4730 40 531 9805 110 1914 1916 164 7073 3371 165 6293 7756 170 9946 2003 179 9654 1700 215 6447 2229 221 3149 3030 242 1999 6843 242 5764 3163 249 3716 8634 250 6801 9317 260 2741 4273 282 5436 4836 284 3951 6483 288 4812 76 375 9004 5492 380 5627 5929 391 6385...
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
378 1 62730 50925 80731 92666 77280 61521 29236 67032 7889 35986 96802 8763 13313 49918 83582 51842 66775 47834 2286 12925 41106 39790 6698 15243 65145 56379 68496 35570 809 525 39834 16723 48002 77230 16273 16032 52615 7621 77300 92267 82517 39917 13170 89084 77751 45638 23868 49631 7758 71381 5191...
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Time Limit Exceeded
input:
100000 100000 299999993 206450345 26023928 334281171 300000008 18107965 318653732 299999990 82338399 299999997 393028366 37212808 299999992 208114125 82126189 300000002 303613195 34463905 270033576 299999993 49200970 300000003 249755524 5829381 300000003 367329175 12867359 300000009 337452692 131045...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...