How to solve this...? I tried but couldnt solve

Ashishgup and Interviews

Problem Code: INTRVS

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t–)
{
int n,k;
cin>>n>>k;
vectors(n);
for(auto &it : s)
{
cin>>it;
}
bool rejected = false;
bool too_slow = false;
bool bot = false;
int too_slow_hai_kya = 0;
int kitne_nhi_kiye = 0;
for(auto it: s)
{
if(it > k)
{
too_slow_hai_kya++;
}
if(it < 0)
{
kitne_nhi_kiye++;
}
}
int temp = n >> 1;
if(kitne_nhi_kiye > (temp))
{
rejected = true;
cout<<“Rejected\n”;
}
if(rejected == false)
{
if(too_slow_hai_kya >= 1)
{
too_slow = true;
cout<<“Too slow\n”;
}
}
if(rejected == false && too_slow == false)
{
// check krle kya pta bot ho
int kitne_kiye_1_sec_ke_andar = 0;
for(auto it: s)
{
if(it >= 0 && it <=1)
{
kitne_kiye_1_sec_ke_andar++;
}
}
if(kitne_kiye_1_sec_ke_andar == n)
{
bot = true;
cout<<“Bot\n”;
}
}
if(bot == false && too_slow == false && rejected == false)
{
cout<<“Accepeted\n”;
}
}
return 0;
}

Please provide well formatted code and link to the problem. Best way to ask is by sharing link to the submission that was incorrect.

1 Like

ok i’ll do that

1 Like

https://www.codechef.com/viewsolution/42850979

Ashishgup and Interviews

Problem Code: INTRVS

1 Like

The error is In line 34, that is,

int temp = n >> 1;

Here you used right shift on n so the original value of n is now changed.

Then you used n in line 59

if(kitne_kiye_1_sec_ke_andar == n)

but original n is changed now. Hence the error.

No, that doesn’t change the value of n.

“Accepted” is spelled wrong (Accepeted).

2 Likes

oh ok, my bad. i used to believe that n>>1 is n = n/2 : (

1 Like

Almost: n >>= 1 is equivalent to n = n / 2 :slight_smile:

1 Like

lol…thanks a lot.

1 Like