先确定窗口左上角可能出现的区域,方法是对每个点确定这样一个区域,然后求交。接下来枚举窗口左上角,计算密码序列,插入一个set中。最后按字典序输出这个set。


/*************************************************************************
Author: WHU_GCC
Created Time: 2007-10-21 10:24:05
File Name: pku3424.cpp
Description: 
***********************************************************************
*/

#include 
<iostream>
#include 
<string>
#include 
<set>
using namespace std;
#define out(x) (cout<<#x<<": "<<x<<endl)
const int maxint=0x7FFFFFFF;
typedef 
long long int64;
const int64 maxint64 = 0x7FFFFFFFFFFFFFFFLL;
template
<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template
<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}

int a[110][2];

set <string> ans;

int main()
{
    
int n;
    
while (scanf("%d"&n) != EOF)
    
{
        
for (int i = 0; i < n; i++)
        
{
            scanf(
"%d%d"&a[i][0], &a[i][1]);
            a[i][
1= -a[i][1];
        }

        ans.clear();
        
        
int x0l = -maxint, x0r = maxint, y0l = -maxint, y0r = maxint;
        
for (int i = 0; i < n; i++)
        
{
            x0l 
>?= a[i][0- 300;
            x0r 
<?= a[i][0];
            y0l 
>?= a[i][1- 300;
            y0r 
<?= a[i][1];
        }

        
        
for (int x0 = x0r; x0 > x0l; x0--)
            
for (int y0 = y0r; y0 > y0l; y0--)
            
{
                
char t[110];
                
int len = 0;
                
int flag = 1;
                
for (int i = 0; i < n; i++)
                
{
                    
int t1 = a[i][0- x0, t2 = a[i][1- y0;
                    
if (t1 < 0 || t1 >= 300 || t2 < 0 || t2 >= 300)
                    
{
                        flag 
= 0;
                        
break;
                    }

                    
int tt = t1 / 100 + t2 / 100 * 3;
                    t[len
++= '1' + tt;
                }

                
if (flag)
                
{
                    t[len] 
= 0;
                    
string ttt = t;
                    ans.insert(ttt);
                }

            }

        
if (ans.size() == 0)
        
{
            printf (
"NONE\n");
        }

        
else
        
{
            
for (set <string> ::iterator it = ans.begin(); it != ans.end(); it++)
                printf (
"%s\n", it->c_str());
        }

        
break;
    }

    
return 0;
}
posted on 2007-10-22 13:48 Felicia 阅读(440) 评论(0)  编辑 收藏 引用 所属分类: 计算几何

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理