惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
Vercel News
Vercel News
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Cloudbric
Cloudbric
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
Security Latest
Security Latest
T
Threatpost
GbyAI
GbyAI
K
Kaspersky official blog
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
V
V2EX
W
WeLiveSecurity
Recorded Future
Recorded Future
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
O
OpenAI News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Attack and Defense Labs
Attack and Defense Labs
N
News | PayPal Newsroom
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Webroot Blog
Webroot Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Troy Hunt's Blog
腾讯CDC
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
E
Exploit-DB.com RSS Feed

博客园 - zy_nic

SRM 424 div1 900 ProductOfPrices 翻译 .. emacs的c++mode contest contest 我的2-sat模板 Solution to GCJ Practice Contest Problem C, Cycles 约瑟夫问题的数学方法 我的模板 图的应用 pku3411 今天的比赛 关于建图的 死老鼠安装成功 先帖个题目上来 hnu 11028 hnu 11015 joj 儿死三八 pku 1273
pku3141
zy_nic · 2007-09-21 · via 博客园 - zy_nic

那个找矩形的,n^4超时了啊- -

#include <stdio.h>
#include 
<string.h>


struct point 
{
    
int x,y;
}
;

point pt[
200];

int px[200],py[200];

int xn,yn;

int n;

int f[200][200][200],g[200][200][200];

int graph[200][200];

int find(int p[],int x,int num)
{
    
int i;
    
for (i=0;i<num;i++)
        
if (p[i]==x) return i;
    
return -1;
}



void ins(int p[],int x,int&num)
{
    
int i;

    
if (find(p,x,num)>=0return ;

    i
=num;
    
if (i>0)
    
while (p[i-1]>x)
    
{
        p[i]
=p[i-1];
        i
--;
        
if (i==0break;
    }

    p[i]
=x;
    num
++;
}




void input()
{
    
int i,j,k,p,q;
    xn
=0;
    yn
=0;
    memset(px,
0,sizeof(px));
    memset(py,
0,sizeof(py));
    
for (i=0;i<n;i++)
    
{
        scanf(
"%d%d",&pt[i].x,&pt[i].y);
        ins(px,pt[i].x,xn);
        ins(py,pt[i].y,yn);

    }




    memset(f,
0,sizeof(f));
    memset(g,
0,sizeof(g));
    memset(graph,
0,sizeof(graph));

    
for (i=0;i<n;i++)
    
{
        p
=find(px,pt[i].x,xn);
        q
=find(py,pt[i].y,yn);
        graph[p][q]
=1;
        f[p][p][q]
=1;
        g[q][q][p]
=1;
    }


    
for (i=0;i<xn;i++)
        
for (j=1;i+j<xn;j++)
            
for (k=0;k<yn;k++)
                f[i][j
+i][k]=f[i][j+i-1][k]+f[i+j][i+j][k];

    
for (i=0;i<yn;i++)
        
for (j=1;j+i<yn;j++)
            
for (k=0;k<xn;k++)
                g[i][j
+i][k]=g[i][i+j-1][k]+g[i+1][i+j][k];

}




    

int main()
{
    
int i,j,p,q;
    
int t=0;

    
while (scanf("%d",&n)==1)
    
{

        
if (n==0break;
        t
++;

        input();


        
int ans=0;
        
for (i=0;i<xn;i++)
            
for (j=i+1;j<xn;j++)
                
for (p=0;p<yn;p++)
                    
for (q=p+1;q<yn;q++)
                    
{
                        
int temp=f[i][j][p]+f[i][j][q]+g[p][q][i]+g[p][q][j]-graph[i][p]-graph[i][q]-graph[j][p]-graph[j][q];

                        
if (temp>ans) 
                        
{
                            
//cout<<"*********"<<endl;
                            
//cout<<i<<' '<<q<<endl;
                        
//    cout<<j<<' '<<p<<endl;
                        

                            ans
=temp;
                        }

                    }

                    printf(
"%s %d: ","Case",t);
        printf(
"%d\n",ans);
    }


    
return 0;
}