11639 - Guard the Land

All about problems in Volume 116. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

mrmbdctg
New poster
Posts: 18
Joined: Sun Mar 04, 2007 7:12 am
Contact:

11639 - Guard the Land

Hello everyone,

Can anyone give me some critical test case for this problem?
Mizanur Rahaman Mizan
USTC, CHITTAGONG
Website:http://www.teronga.com

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11639 - Guard the Land

IT is a easy problem....There is no ticky test case.......
HERE is two test cases..........
try it.......

Code: Select all

2
0 0 1 1
0 1 2 3
0 0 1 1
0 0 1 1
out put:

Code: Select all

Night 1: 0 5 9995
Night 2: 1 0 9999

nazmuldiu
New poster
Posts: 4
Joined: Wed Aug 05, 2009 6:05 pm

Re: 11639 - Guard the Land

Dear Saiful,
My Code is giving same output as yours given input. But getting WA. Would you please provide more inputs to test my code?
Here is My Code:

Code: Select all

# include <stdio.h>
# include <math.h>

int main()
{
int x1,x2, x3,x4, y1,y2,y3,y4;
int T,i;
int strongArea, weakArea, unsecuredArea;
int rectA,rectB;

//freopen("e:\\11639.in","r",stdin);
scanf("%d",&T);
for(i=1; i<=T; i++)
{
scanf("%d%d%d%d",&x1,&y1,&x3,&y3);
scanf("%d%d%d%d",&x2,&y2,&x4,&y4);

if( x2>x3 || y2>y3 )
strongArea = 0;
else
strongArea = abs( (x2-x3)*(y2-y3) );

rectA = abs( (x1-x3)*(y1-y3) ) - strongArea;
rectB = abs( (x2-x4)*(y2-y4) ) - strongArea;

weakArea = rectA + rectB;
unsecuredArea = 10000 - ( weakArea + strongArea );

printf("Night %d: %d %d %d\n",i,strongArea,weakArea,unsecuredArea);

}
return 0;
}

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11639 - Guard the Land

Hello nazmul

ur code donot pass this case:
try it........
input:

Code: Select all

1
3 3 3 3
1 1 1 1
out put:

Code: Select all

Night 1: 0 0 10000

aliahmed
New poster
Posts: 24
Joined: Fri Oct 24, 2008 8:37 pm
Location: CUET, Chittagong, Bangladesh
Contact:

Re: 11639 - Guard the Land

Acc

CODE REMOVED
Last edited by aliahmed on Tue Nov 03, 2009 12:10 pm, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 11639 - Guard the Land

Try this case..

Code: Select all

1
10 10 20 20
15 5 16 26
My output is..

Code: Select all

Night 1: 10 101 9889

Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

11639 - Guard the Land

#include<iostream.h>
#include<stdio.h>
int main()
{
int i,j,n,x1,x2,x3,x4,y1,y2,y3,y4,strong,total,weak,sign1,sign2,sign3,sign4,sign5,sign6;
cin>>n;
for(int k=1;k<=n;k++)
{ sign1=0,sign2=0,sign3=0,sign4=0,sign5=0;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
if(x1>x3){i=x1;j=y1;
x1=x3;y1=y3;
x3=i;y3=j;
i=x2;j=y2;
x2=x4;y2=y4;
x4=i;y4=j;}
if((x1==x3&&y1==y3)&&(x2==x4&&y2==y4))
sign1=1;
else if((x1<=x3&&x3<x2&&y3<=y1&&y2<=y4))
{ sign6=1;//cout<<"check 6";
}
else
{
if((x1<=x3&&x3<x2)&&(y1<=y3&&y3<y2))
sign2=1;
if((x1<=x4&&x4<x2)&&(y1<=y3&&y3<y2))
sign3=1;
if((x1<=x4&&x4<x2)&&(y1<=y4&&y4<y2))
sign4=1;
if((x1<=x3&&x3<x2)&&(y1<=y4&&y4<y2))
sign5=1;
}
total=10000;
if(sign1==1){ strong=(x2-x1)*(y2-y1);
weak=0;total=total-strong; //cout<<"sign1";
}
else if(sign6==1)
{
strong=(x4-x3)*(y2-y1);
weak=(x2-x1)*(y2-y1)+(x4-x3)*(y4-y3)-2*strong;
total=total-weak-strong; //cout<<"signal 6";
}
else if(sign2==1&&sign3!=1&&sign4!=1&&sign5!=1)
{ strong=(x2-x3)*(y2-y3);
weak=((x2-x1)*(y2-y1))+((x4-x3)*(y4-y3))-2*strong;
total=total-weak-strong; // cout<<"sign2";
}
else if(sign2==1&&sign3==1&&sign4!=1&&sign5!=1)
{
strong=(x4-x3)*(y2-y3);
weak=((x2-x1)*(y2-y1))+((x4-x3)*(y4-y3))-2*strong;
total=total-weak-strong; // cout<<"sign3";
}
else if(sign2==1&&sign3!=1&&sign4!=1&&sign5==1)
{
strong=(x2-x3)*(y4-y3);
weak=((x2-x1)*(y2-y1))+((x4-x3)*(y4-y3))-2*strong;
total=total-weak-strong; // cout<<"sign4";
}
else if(sign2==1&&sign3==1&&sign4==1&&sign5==1)
{
strong=(x4-x3)*(y4-y3);
weak=((x2-x1)*(y2-y1))-strong;
total=total-weak-strong; //cout<<"sign5";
}
else if(sign2!=1&&sign3!=1&&sign4!=1&&sign5!=1&&sign6!=1)
{
strong=0;
weak=(x2-x1)*(y2-y1)+(x4-x3)*(y4-y3);
total=total-weak; // cout<<"sign !=1";
}
else{cout<<"stop it";}
// cout<<x1<<y1<<x2<<y2<<x3<<y3<<x4<<y4;
cout<<"Night "<<k<<": "<<strong<<" "<<weak<<" "<<total<<endl;
}
return 0;
}

mostafiz93
New poster
Posts: 31
Joined: Thu Nov 24, 2011 12:08 am

Re: 11639 - Guard the Land

this test case
mrmbdctg wrote:Hello everyone,

Can anyone give me some critical test case for this problem?
try this test case :

input:

Code: Select all

9
10 10 20 20
10 10 20 20

10 10 20 20
10 10 20 15

10 10 20 25
10 10 20 20

10 10 20 15
10 10 20 20

10 10 20 20
10 10 20 25

10 10 20 20
15 15 25 25

10 10 20 20
20 20 30 30

10 10 20 20
5 5 9 9

10 10 20 20
15 5 16 26
output:

Code: Select all

Night 1: 100 0 9900
Night 2: 50 50 9900
Night 3: 100 50 9850
Night 4: 50 50 9900
Night 5: 100 50 9850
Night 6: 25 150 9825
Night 7: 0 200 9800
Night 8: 0 116 9884
Night 9: 10 101 9889