#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<stdio.h>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long int lld;
struct node{
node *left,*right;
lld x1,x2,y1,y2;
lld lazy;
lld val;
public:
void set(lld X1,lld X2,lld Y1,lld Y2){
x1=X1;
x2=X2;
y1=Y1;
y2=Y2;
lazy=0;
val=0;
}
};
void extend(node *n){
if(!n->left){
if(n->x1==n->x2){
if(n->y1==n->y2)return;
lld mid=(n->y1+n->y2)/2;
n->left=new node();
n->right=new node();
n->left->set(n->x1,n->x2,n->y1,mid);
n->right->set(n->x1,n->x2,mid+1,n->y2);
return;
}
lld mid=(n->x1+n->x2)/2;
n->left=new node();
n->right=new node();
n->left->set(n->x1,mid,n->y1,n->y2);
n->right->set(mid+1,n->x2,n->y1,n->y2);
return;
}
}
void prop(node *n){
if(n->lazy!=0){
n->val+=(n->x2-n->x1+1)*(n->y2-n->y1+1)*n->lazy;
extend(n);
if(n->left){
n->left->lazy+=n->lazy;
n->right->lazy+=n->lazy;
}
n->lazy=0;
}
}
void update(node *n,lld x1, lld x2, lld y1,lld y2,lld val){
extend(n);
prop(n);
//cout<<n->x1<<" "<<n->x2<<" "<<n->y1<<" "<<n->y2<<endl;
if(n->x1>x2 || n->x2<x1 || n->y1>y2 || n->y2<y1)return;
if(x1<=n->x1 && n->x2<=x2 && y1<=n->y1 && n->y2<=y2){
n->lazy+=val;
prop(n);
return;
}
update(n->left,x1,x2,y1,y2,val);
update(n->right,x1,x2,y1,y2,val);
n->val=n->left->val+n->right->val;
}
lld query(node *n,lld x1, lld x2, lld y1,lld y2){
//cout<<n->x1<<" "<<n->x2<<" "<<n->y1<<" "<<n->y2<<" "<<n->val<<endl;
//cout<<(n->x1>x2)<<" "<<x2<<endl;
if(n->x1>x2 || n->x2<x1 || n->y1>y2 || n->y2<y1)return 0;
extend(n);
prop(n);
if(x1<=n->x1 && n->x2<=x2 && y1<=n->y1 && n->y2<=y2){
//cout<<n->x1<<" "<<n->x2<<" "<<n->y1<<" "<<n->y2<<" "<<n->val<<endl;
return n->val;
}
return query(n->left,x1,x2,y1,y2)+query(n->right,x1,x2,y1,y2);
}
node *ST;
int main(){
/*int n;
cin>>n;*/
node *S=new node();
S->set(0,400000,0,400000);
/*update(S,0,1,0,1,1);
update(S,1,1,0,1,1);
//update(S,1,2,1,2,1);
cout<<query(S,0,2,0,2)<<endl;
//extend(S);*/
int n;
cin>>n;
lld rect[n][4];
vector<lld> coord;
for(int i=0;i<n;i++){
for(int j=0;j<4;j++){
cin>>rect[i][j];
if(j>=2)rect[i][j]+=rect[i][j-2]-1;
//cout<<rect[i][j]<<" ";
}//cout<<endl;
}
for(int i=0;i<n;i++){
for(int j=0;j<4;j++){
coord.push_back(rect[i][j]);
//cout<<rect[i][j]<<" ";
}//cout<<endl;
}
sort(coord.begin(),coord.end());
for(int i=0;i<n;i++){
for(int j=0;j<4;j++){
int lo,hi;
lo=0;
hi=coord.size()-1;
while(hi>lo){
int mid=(hi+lo)/2;
if(coord[mid]==rect[i][j]){
hi=mid;
lo=mid;
}
if(coord[mid]<rect[i][j])lo=mid+1;
if(coord[mid]>rect[i][j])hi=mid-1;
}
rect[i][j]=lo;
//cout<<rect[i][j]<<" ";
}//cout<<endl;
}
bool ans[n];
for(int i=n-1;i>-1;i--){ans[i]=false;
if(query(S,rect[i][0],rect[i][2],rect[i][1],rect[i][3])==0)ans[i]=true;
update(S,rect[i][0],rect[i][2],rect[i][1],rect[i][3],1);
//cout<<S->val<<endl;
}
for(int i=0;i<n;i++){
//cout<<ans[i]<<endl;
if(ans[i])cout<<"DA"<<endl;
else cout<<"NE"<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
395 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
367 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
401 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
430 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
483 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
467 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
476 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
520 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
579 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
637 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |