⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3566432_ac_16ms_480k.cc

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CC
字号:
#include <set>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int n;

struct Point
{
	string name;
	int x, y;
	bool operator < (const Point &that)	const
	{
		return x < that.x;
	}

	bool operator == (const Point &that)	const
	{
		return x == that.x && y == that.y;
	}
}p[26];

typedef set <string> SS;
SS ans;
SS::iterator it;

int find(Point pt)
{
	int i;

	for (i = 0; i < n; i++)
	{
		if (p[i] == pt)
		{
			return i;
		}
	}
	return -1;
}

int main()
{
	int cas = 1;
	int i, j;

	while (cin >> n && n)
	{
		printf("Point set %d:", cas++);
		for (i = 0; i < n; i++)
		{
			cin >> p[i].name >> p[i].x >> p[i].y;
		}
		sort(p, p + n);
		ans.clear();
		for (i = 0; i < n; i++)
		{
			for (j = i + 1; j < n; j++)
			{
				if (p[i].x == p[j].x || p[i].y <= p[j].y)
				{
					continue;
				}
				int i1 = find((Point){"", p[i].x, p[j].y});
				int i2 = find((Point){"", p[j].x, p[i].y});
				if (i1 != -1 && i2 != -1)
				{
					ans.insert(p[i].name + p[i2].name
						+ p[j].name + p[i1].name);
				}
			}
		}
		if (ans.empty())
		{
			cout << " No rectangles" << endl;
			continue;
		}
		cout << endl;
		int cnt = 0;
		for (it = ans.begin(); it != ans.end(); ++it)
		{
			cout << " " << (*it);
			if (cnt == 9)
			{
				cout << endl;
				cnt = 0;
			}
			else
			{
				cnt++;
			}
		}
		if (cnt != 0)
		{
			cout << endl;
		}
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -