Tough TCS Codevita: Zone 2

I don’t know what is happening in string pair

5 Likes

I was able to solve one question tha string pair
Got presentation error in public test case and TLE in private any chance of round 2 for me? :pleading_face:

Yes what i did is -

def ispali(s):
    r = s[::-1]
    return (r==s)

cnt=0

st , en = map(int,input().split(' '))
for i in range(st,en+1):
    s1 = str(i)
    for hr in range(0,24):
      s2 = (2-len(str(hr)))*'0' + str(hr)
      for mini in range(0,60):
          s3 = (2-len(str(mini)))*'0' + str(mini)
          for sec in range(0,60):
              s4 = (2-len(str(sec)))*'0' + str(sec)
              if(ispali(s1+s2+s3+s4)):
                  cnt+=1

print(cnt)

#approach 2

cnt=0
for i in range(st,en+1):
    for j in range(0,86400):
        x = j
        hr = x//3600
        x = x%3600
        mini = x//60
        x = x%60
        sec = x%60
        
        s2 = (2-len(str(hr)))*'0' + str(hr)
        s3 = (2-len(str(mini)))*'0' + str(mini)
        s4 = (2-len(str(sec)))*'0' + str(sec)
        
        if(ispali(str(i) + s2+s3+s4)):
            cnt+=1
print(cnt)


#both give same answer for
# 1 2 
# 288
1 Like

Yes I too wasted my 2 hrs trying to figure out where i went wrong

288 was coming for 1 sample, no?

Yes and 432

yes likha to .

Had anyone got “Unlocker” problem?

4 Likes

Anyone solved any of these questions? Please share your approach
Count palindrome
Even odd
Moving average
Tennis Score
subnetting
String merge.

Why kind of peps are working at TCS?
Or I misunderstood the question?

Do they give partial marking for not passing all the test cases??

Many people has share ss of graph in tcscodevita contest,
from where they get the graph and after what time ending of zone 1

Did you get all these problems in your problem set?

tried many ways and covered all the corner cases but still WA on private test cases. Dont know what else we had to do with it.

I have solved Election Problem and String pair was getting wrong answer.
can anyone who can help in string pair one

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second
ll fun(string s)
{
   ll count=0;
   for(int i=0;i<(int)s.length();i++)
   {
   	if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
   	{
   		count++;
   	}
   }
   return count;
}
void solve()
{
   int n;
   cin>>n;
   int arr[n];
   string s[]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen",
"fourteen","fifteen","sixteen","seventeen",	"eighteen",	"nineteen","twenty","twenty one","twenty two","twenty three","twenty four","twenty five",
"twenty six",
"twenty seven",
"twenty eight",
"twenty nine",
"thirty",
"thirty one",	
"thirty two",	
"thirty three",
"thirty four",
"thirty five",
"thirty six",	
"thirty seven",
"thirty eight",
"thirty nine",
"forty","forty one","forty two","forty three","forty four","forty five","forty six","forty seven","forty eight","forty nine","fifty","fifty one","fifty two",
"fifty three","fifty four","fifty five","fifty six","fifty seven","fifty eight","fifty nine","sixty","sixty one","sixty two","sixty three","sixty four","sixty five","sixty six","sixty seven",
"sixty eight","sixty nine","seventy","seventy one","seventy two","seventy three","seventy four","seventy five","seventy six","seventy seven","seventy eight","seventy nine",
"eighty","eighty one","eighty two","eighty three","eighty four","eighty five","eighty six","eighty seven","eighty eight","eighty nine","ninety","ninety one","ninety two","ninety three",
"ninety four","ninety five","ninety six","ninety seven","ninety eight","ninety nine","hundred"};
   for(int i=0;i<n;i++)
   {
   	cin>>arr[i];
   	//cout<<s[arr[i]]<<endl;
   }
   vector<ll> val;
   for(int i=0;i<n;i++)
   {
   	val.push_back(fun(s[arr[i]]));
   }
   ll sum=0;
   for(int i=0;i<(int)val.size();i++)
   {
   	sum+=val[i];
   }
   //sort(arr,arr+n);
   ll res=0;
   set<pair<ll,ll>> se;
   vector<bool> vis(n,false);
   for(int i=0;i<n;i++)
   {
   		for(int j=i+1;j<n;j++)
   		{
   		
   			if(!vis[i] && !vis[j] && arr[i]+arr[j]==sum)
   			{
   				res++;
   				vis[i]=true;
   				vis[j]=true;
   			}
   		}
   }
   if(res>100)
   {
   	cout<<"greater 100"<<endl;
   }
   else
   {
   	
   	cout<<s[res]<<endl;
   	
   }
   
}
int main()
{
//	ios_base::sync_with_stdio(false); 
 //  cin.tie(NULL);  
   int t;
   t=1;
   while(t--)
   {
   	solve();
   }
}
2 Likes

did any one solved that question. coz i got WA though i take care of “hundred”. Is there any corner case which i missed;

yeah bro, i gave around 2 hrs to that question but it didn’t pass private cases.

My friends tried to solve that question a lot. Nothing worked. This question (together with a lot of other questions) was a complete goo. They didn’t tell whether to print 21 has twenty one or twentyone or twenty-one. They didn’t clearly define what they mean by unordered pairs. In case of (2, 3) does (2, 2) also count? Do we have to make the unordered pairs on the indices of the given array or treat the elements of the given array as a set?
It was a complete mess.

I can bitch about a lot of their questions.

12 Likes

i wasted 1hr on this question, testcase were worng, i have also searched it on internet thier i find the only possible way to get the answer is when take minute in range[0,98) and it got accepted, such a senseless question.

1 Like

what the fk :frowning: