MockVita Round 2 2018

Hello friends can someone tell me how to approach these problems? I participated in this practice round in the morning and could not solve these 3 problems. Can someone tell me the approach to solve these problems. Thanks in advance.

@vijju123 @taran_1407 @vivek_1998299 @meooow @john_smith_3 @aryanc403 @vbt_95

[Problem 1 ][1] [Problem 2][2] [Problem 3][3]

Note Contest is over so we can have a discussion over the approach used or can be used.
[1]: ar.pdf - Google Drive
[2]: daa.pdf - Google Drive
[3]: fa.pdf - Google Drive

I am curious about A problem.

The problem name was great circles or something like that.

Test case:-

0N,47E
45N,47E
45S,47E

The first angle in this test case comes about to be less than 45 degrees but was simply taken as 45 degrees by the problem author. I don’t understand how atan(45/47) is 45 degrees. Did anyone else face a similar problem.?

yes, same issue faced by me here.

it was easy guys. There is a simple formula for the same. What about 4th, 5th and 6th problems?

yes, it was simple, but they had a pathetic compiler. I got results after like an hour only to receive compilation error lol.

1 Like

agree with this :slight_smile:

What formula?

#include<stdio.h>
int a[10][10];
void del(int i,int j,int s,int f,int r,int c)
{
int k,l;
if(s==0)
{
for(k=0;k<r;k++)
for(l=j;l<c;l++)
a[k][l]=f-1;
}
else
{
for(k=i;k<r;k++)
for(l=0;l<c;l++)
a[k][l]=f-1;
}
}
int rsum(int i,int j,int r,int c)
{
int k,l,s=0;
for(k=0;k<i;k++)
for(l=0;l<c;l++)
s+=a[k][l];
return s;
}
int csum(int i,int j,int r,int c)
{
int k,l,s=0;
for(k=0;k<r;k++)
for(l=0;l<j;l++)
s+=a[k][l];
return s;
}
int main()
{
int i,j,k,r,c,max=0,r1,c1,s,t1,t2,sum=0;
char ch;
scanf("%d%c%d",&r,&ch,&c);
r1=r;
c1=c;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
if(j<c-1)
scanf("%c",&ch);
if(a[i][j] > max)
max=a[i][j];
}
for(k=1;k<=max;k++)
{
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
{
if(a[i][j] < k)
{
t1=rsum(i,j,r1,c1);
t2=csum(i,j,r1,c1);
s=(t1 > t2) ? 1 : 0;
del(i,j,s,k,r1,c1);
if(s==1)
r1=i;
else
c1=j;
}
}
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
sum+=a[i][j];
}
printf("%d",sum);
return 0;
}
let me know ,if it works