Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct
- {
- int x;
- int y;
- } gaura;
- gaura G[1001];
- int Amax=0;
- int n,m;
- void taiere( int sus, int stanga, int jos, int dreapta, int ultimul=1)
- {
- if(Amax > (jos-sus+1)*(dreapta-stanga+1))
- {
- return;/// nu are rost sa cautam
- }
- int i;
- for(i=ultimul;i<=m;i++)
- {
- if(G[i].x >= sus && G[i].x <=jos && G[i].y<=dreapta && G[i].y >= stanga)
- {
- taiere(sus, stanga,G[i].x-1,dreapta,i+1);
- taiere(G[i].x+1,stanga,jos,dreapta,i+1);
- taiere(sus,stanga,jos,G[i].y-1,i+1);
- taiere(sus, G[i].y+1,jos,dreapta,i+1);
- return ;
- }
- }
- if( Amax < (jos-sus+1)*(dreapta-stanga+1))
- {
- Amax=(jos-sus+1)*(dreapta-stanga+1);
- //printf("%d %d %d %d %d \n ",sus,stanga,jos,dreapta, Amax);
- }
- }
- int main()
- {
- freopen("hambar.in","r+",stdin);
- freopen("hambar.out","w+",stdout);
- scanf("%d %d",&n,&m);
- int i,j;
- for(i=1;i<=m;i++)
- {
- scanf("%d %d ",&G[i].x,&G[i].y);
- }
- taiere(1,1,n,n);
- printf("%d",Amax);
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement