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

📄 2222.cpp

📁 这是哈尔滨工业大学acmOJ的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 2222 on 2006-05-14 at 20:33:09 */ 
#include <cstdio>
#include <algorithm>
using namespace std;

const int VM = 10;
const int LM = 56;

class Line {
private:
	class Point { public: int x, y; } v[VM];
	void direct(const Point&, const Point&, int&, int&);
public:
	int m, l[VM][2], d[VM][2];
	void make();
	bool same(const Line&) const;
};
void Line::make() {
	scanf("%d", &m);
	int i, j;
	for(i = 0; i < m; i++) scanf("%d %d", &v[i].x, &v[i].y);
	for(i = 0; i < m-1; i++) direct(v[i], v[i+1], d[i][0], l[i][0]);
	for(i = m-1; i > 0; i--) direct(v[i-1], v[i], d[m-1-i][1], l[m-1-i][1]);
	for(i = m-2; i >= 0; i--) 
		for(j = 0; j < 2; j++) d[i][j] = (d[i][j]-d[0][j])&3;
}
void Line::direct(const Point& a, const Point& b, int& pd, int& pl) {
	if(b.x > a.x) pd = 0;
	else if(b.y < a.y) pd = 1;
	else if(b.x < a.x) pd = 2;
	else pd = 3;
	pl = abs(b.x-a.x)+abs(b.y-a.y);
}
bool Line::same(const Line& le) const {
	if(m != le.m) return false;
	int i, j; bool sm[2] = { true, true };
	for(i = 0; i < m-1; i++)
		for(j = 0; j < 2; j++)
			if(l[i][0] != le.l[i][j] || (d[i][0] != le.d[i][j])) sm[j] = false;
	return sm[0] || sm[1];
}

int main()
{
	Line line[LM];
	int i, n;
	
	while(scanf("%d", &n) != EOF && n != 0) {
		n++;
		for(i = 0; i < n; i++) line[i].make();
		for(i = 1; i < n; i++)
			if(line[0].same(line[i])) printf("%d\n", i);
		printf("+++++\n");
	}
	
	return 0;
}

⌨️ 快捷键说明

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