OJ-POJ1021-暴力

这题网上有代码量很少的解法,可惜我看不明白。

先不管题目,讨论如何判断两个图形相同(旋转,平移,翻转)?

就是如下8个图形中,任选出两个,要得出它们是两个相同的图形:


我的方法特土特暴力:列出8种,然后分别比较。。。

回到题目,自己的理解是(对左右两个板):

a,找到群。要求左右,群数相同,群中点数相同
b,群中点数相同的,一定有一对一相同的形状

分析过程:

1,找群,这里犯了一个错误,不能只用点,应该从上到下从左到右遍历板

2,群按照群中点数排序,每个点数中的群数应该是一样的。

3,对每个点数中的群,左右必须有一一对应的关系。

贴一份AC代码,findClusters方法就是错误的找群方法,正确的是findClusters2

package poj10x;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

/*
 * 	status : Accept
 * 	Memory 	Time
 * 	3772K	204MS
 * 	
 */

/*
 * 	text file encoding : utf8
 * 	大意:
 * 		1,意思非常绕口
 * 		2,先说操作吧:
 * 			a,删除连续的一行或者一列
 * 			b,删除最后一块的胜利
 * 			c,左右两个板,要求是左边赢的操作,在右边同样赢
 * 		3,自己的理解(以下说辞都是对左右两个板):
 * 			a,找到群。要求左右,群数相同,群中点数相同
 * 			b,群中点数相同的,一定有一对一相同的形状
 * 	输入:
 * 		2(测试数)
 * 		8 5 11(X,Y,点个数)
 * 		0 0 1 0 2 0 5 0 7 0 1 1 2 1 5 1 3 3 5 2 4 4
 * 		0 4 0 3 0 2 1 1 1 4 1 3 3 3 5 2 6 2 7 2 7 4
 * 		8 5 11
 * 		0 0 1 0 2 0 5 0 7 0 1 1 2 1 5 1 3 3 6 1 4 4
 * 		0 4 0 3 0 2 1 1 1 4 1 3 3 3 5 2 6 2 7 2 7 4
 * 	输出:
 * 		YES(左右相同)
 * 		NO(左右不相同)
 */

public class P1021 {
	static int bigX, bigY;
	static Point p[], p_other[], p_this[];
	static Cluster cluster_save;
	static Cluster[] arrayOfCluster;
	static ClusterMap[] clusterMap_this, clusterMap_other;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numOfTest = scanner.nextInt();
		while(numOfTest -- > 0) {
			bigX = scanner.nextInt();
			bigY = scanner.nextInt();
			p = new Point[scanner.nextInt()];
			p_other = new Point[p.length];
			p_this = new Point[p.length];
			for (int indexOfPoint = 0; indexOfPoint < p.length; indexOfPoint ++) {
				p[indexOfPoint] = new Point(scanner.nextInt(), scanner.nextInt());
				p_this[indexOfPoint] = p[indexOfPoint];
			}
			arrayOfCluster = findClusters2();
			Arrays.sort(arrayOfCluster);
			clusterMap_this = getClusterMap();
			for (int indexOfPoint = 0; indexOfPoint < p.length; indexOfPoint ++) {
				p[indexOfPoint] = new Point(scanner.nextInt(), scanner.nextInt());
				p_other[indexOfPoint] = p[indexOfPoint];
			}
			arrayOfCluster = 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值