AcWing 3198. 窗口
原题链接
简单
作者:
把这题Ac了
,
2024-11-09 11:39:57
,
所有人可见
,
阅读 2
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 20;
typedef pair<int,int> PII;
struct node{
int a,b,c,d;
}edge[N];
int d[N][4];
int stk1[N],stk2[N];
int t1 = -1,t2 = -1;
int n,m;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
int a,b,c,d;
cin >> a >> b >> c >> d;
edge[i] = {a,b,c,d};
}
for(int i = 1;i <= n;i++)
stk1[++t1] = i;
while(m--){
int l,r,top_num,flag = 0;
cin >> l >> r;
while(t1 >= 0){
int top_num = stk1[t1];
int x1 = edge[top_num].a,y1 = edge[top_num].b;
int x2 = edge[top_num].c,y2 = edge[top_num].d;
if(l >= x1 && l <= x2 && r >= y1 && r <= y2){
flag = 1;
cout << top_num << endl;
break;
}else{
stk2[++t2] = stk1[t1--];
}
}
if(t1 < 0){
cout << "IGNORED" << endl;
}
if(flag){
top_num = stk1[t1--];
}
while(t2 >= 0){
stk1[++t1] = stk2[t2--];
}
if(flag){
stk1[++t1] = top_num;
}
}
return 0;
}