Home > Web Front-end > H5 Tutorial > body text

About the CCF CSP window

坏嘻嘻
Release: 2018-09-14 14:02:16
Original
2357 people have browsed it

XSS cross-site scripting attack, bypassing the same origin policy through fake content and click bait. This is a big problem, and if an attacker successfully injects code, a considerable amount of user data can be leaked.

Problem Description

In a certain graphics operating system, there are N windows, each window is a rectangular area with both sides parallel to the coordinate axis. . Points on the boundary of the window also belong to the window. There are hierarchical differences between windows. In an area where more than one window overlaps, only the content in the top-level window will be displayed.
When you click a point on the screen, you select the top-level window at the clicked position, and this window will be moved to the top-level of all windows, while the hierarchical order of the remaining windows remains unchanged. If the location you click does not belong to any window, the system will ignore your click.
Now we want you to write a program to simulate the process of clicking on a window.

Input format

The first line of input contains two positive integers, namely N and M. (1 ≤ N ≤ 10,1 ≤ M ≤ 10)
 The next N lines give the positions of N windows in order from the bottom to the top. Each line contains four non-negative integers x1, y1, x2, y2, indicating a pair of vertex coordinates of the window (x1, y1) and (x2, y2). It is guaranteed that x1 < x2,y1 2.
Each of the next M lines contains two non-negative integers x and y, representing the coordinates of a mouse click.
The x and y coordinates of all points and the vertices of the rectangle involved in the question do not exceed 2559 and 1439 respectively.

Output format

The output includes M lines, each line represents the result of a mouse click. If a window is selected by this mouse click, the number of this window is output (windows are numbered from 1 to N in the order in the input); if not, "IGNORED" (without double quotes) is output.

Sample input

3 4
0 0 4 4
1 1 5 5
2 2 6 6
1 1
0 0
4 4
0 5

Sample output

2
1
1
IGNORED

Sample description

The position clicked for the first time belongs to both the 1st and 2nd windows, but since the 2nd window is on top, it is selected and brought to the top.
 The position clicked for the second time only belongs to the first window, so this click selects this window and brings it to the top. The hierarchical relationship between the three windows now is exactly the opposite of the initial state.
The position clicked for the third time belongs to the range of three windows at the same time, but since the first window is now at the top level, it is selected.
 The last clicked (0, 5) does not belong to any window.

Analysis: It is a very simple question, there is no difficulty, as long as the order is sorted out.

#include <iostream>
#include<vector>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int>win;
	vector<int>::iterator it;
	for (int i = N; i > 0; i--)
	{
		win.push_back(i);
	}
	int position[11][4];
	int cli[13][2];
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			cin >> position[i][j];
		}
	}
	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < 2; j++)//由于写这个的时候精神状态不是很好,原来写成j>2了。后来实在找不到哪里错了,只好把for循环重写了一遍。
		{
			cin >> cli[i][j];
		}
	}
	for (int i = 0; i < M; i++)
	{
		bool you = true;
		for (int j = 0; j < N; j++)
		{
			if (cli[i][0] >= position[win[j]][0] && cli[i][0] <= position[win[j]][2] && cli[i][1] >= position[win[j]][1] && cli[i][1] <= position[win[j]][3])
			{
				cout << win[j] << endl;
				you = false;
				if (j != 0)
				{
					int a = win[j];
					for (it = win.begin(); it != win.end();)
					{
						if (*it == a)
						{
							it = win.erase(it);
						//	break;
						}   //删除元素,返回值指向已删除元素的下一个位置
						else
						{
							++it;
						}    //指向下一个位置
					}
					win.insert(win.begin(), a);
				}
				break;
			}
		}
		if (you)
		{
			cout << "IGNORED" << endl;
		}
		
	}
	return 0;
}
Copy after login

Related recommendations:

HTML5 Security Introduction Introduction to Content Security Policy (CSP)_html5 Tutorial Skills

html5 Basic tags (html5 video tag html5 new tag usage)_html5 tutorial skills

The above is the detailed content of About the CCF CSP window. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!