ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1572. Yekaterinozavodsk Great Well

WA5
Posted by shadows_s 29 Jun 2012 18:55
Or give some test cases.

#include <iostream>
using namespace std;

struct figure {
int type;
int size;
};

bool (*figureFunction) (int, figure);

bool circle (int holeSize, figure inManhole)
{
if( inManhole.type == 1 )
return holeSize >= inManhole.size;
return 2*holeSize >= inManhole.size;
}

bool triangle (int holeSize, figure inManhole)
{
if( inManhole.type == 3 ) return holeSize >= inManhole.size ;
return holeSize > inManhole.size ;
}

bool square(int holeSize, figure inManhole)
{
switch(inManhole.type)
{
case 1: return sqrt(2)*holeSize >= 2*inManhole.size;
case 2: return holeSize >= inManhole.size;
case 3: return sqrt(2)*holeSize >= inManhole.size;
default: break;
}
}

int testHole( figure hole, figure* manhole, int count)
{
int willPut = 0;

switch( hole.type ){
case 1: figureFunction = &circle; break;
case 2: figureFunction = &square; break;
case 3: figureFunction = &triangle; break;
default: break;
}

for( int i = 0; i<count; ++i )
{
if(figureFunction( hole.size, manhole[i] )) willPut++;
}
return willPut;
}

int main()
{
figure hole;
cin>>hole.type>>hole.size;

int count;
cin>>count;
figure* manhole = new figure[count];
for( int i=0; i<count; ++i )
{
cin>>manhole[i].type>>manhole[i].size;
}

cout<< testHole( hole, manhole, count);

delete manhole;

return 0;
}

Edited by author 29.06.2012 18:56
Re: WA5
Posted by Nikita 2 May 2016 18:08
WA#5
2 10
1
3 15

WA#6
3 10
1
3 11

circle:   maxSize := 2 * a;
minSize := 2 * a;
square:   maxSize := a * sqrt(2);
minSize := a;
triangle: maxSize := a;
minSize := a * sqrt(3) / 2;
Re: WA5
Posted by Bogdan Lobanov 9 Mar 2018 20:37
Thank yo so much ! (i forget about min size triangle :-) )
Nikita wrote 2 May 2016 18:08
WA#5
Re: WA5
Posted by Rinotto 4 Apr 2018 00:57
WA5 - Try to put the circle into the square!!!