this solution give tle

#include<bits/stdc++.h>
using namespace std;

int main()
{

        int t;
        cin>>t;
        
        for(int tt = 1;tt<=t;tt++)
        {
                int n,l;
                cin>>n>>l;
        
                string arr[n];
                map < string , int > ms;

                for(int i=0;i<n;i++)
                {
                        cin>>arr[i];
                        ms[arr[i]]=1;
                }
                int flag=0;
                for(int i=0;i<n;i++)
                {
                        for(int j=0;j<l;j++)
                        {
                                string temp;
                                temp = arr[i].substr(0, j+1);
                                for(int k=0;k<n;k++)
                                {
                                    int xxxx = fun(100);
                                        if(k!=i)
                                        {
                                                string x = arr[k].substr(j+1, 
l-j-1);
                                                string f = temp +x;
                                                if(ms.count(f))
                                                        continue;
                                                else
                                                {
                                                        cout<<"Case #"<<tt<<": 
"<<f<<endl;
                                                        flag=1;
                                                        break;
                                                }
                                        }
                                }
                                if(flag==1)
                                        break;
                        }
                        if(flag==1)
                                break;
                }
                if(flag==0)
                        cout<<"Case #"<<tt<<": -"<<endl;
        }
        
        return 0;
}


but when i playing around my code and submitted my code with some useless 
function call make my code submission successful

this is my another code

#include<bits/stdc++.h>
using namespace std;

//this is that useless function which is called always in my for loop
int fun(int a)
{
    return a;
}

int main()
{

        int t;
        cin>>t;
        
        for(int tt = 1;tt<=t;tt++)
        {
                int n,l;
                cin>>n>>l;
        
                string arr[n];
                map < string , int > ms;

                for(int i=0;i<n;i++)
                {
                        cin>>arr[i];
                        ms[arr[i]]=1;
                }
                int flag=0;
                for(int i=0;i<n;i++)
                {
                        for(int j=0;j<l;j++)
                        {
                                string temp;
                                temp = arr[i].substr(0, j+1);
                                for(int k=0;k<n;k++)
                                {  //calling statement
                                    int xxxx = fun(100);
                                        if(k!=i)
                                        {
                                                string x = arr[k].substr(j+1, 
l-j-1);
                                                string f = temp +x;
                                                if(ms.count(f))
                                                        continue;
                                                else
                                                {
                                                        cout<<"Case #"<<tt<<": 
"<<f<<endl;
                                                        flag=1;
                                                        break;
                                                }
                                        }
                                }
                                if(flag==1)
                                        break;
                        }
                        if(flag==1)
                                break;
                }
                if(flag==0)
                        cout<<"Case #"<<tt<<": -"<<endl;
        }
        
        return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/4f6c8a44-0f27-42a9-ac16-13de92a05d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to