What's wrong with my code @fredric, it gives the correct answer for the
test case, please have a look and let me know!
1
107 29
15 15 15 15 21 49 77 143 221 323 437 667 899 1147 1517 1763 2021 2491 3127
3599 4087 4757 5183 5767 6557 7387 8633 9797 10403


#include<bits/stdc++.h>
using namespace std;
int* SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    int *arr=new int[78499];
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
  int flag=0;
    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p]){
          // cout << p << " ";
            arr[flag++]=p;
    }
        // cout<<flag<<endl;
        return arr;
}

int main(){
int t=0;
cin>>t;
int cse=0;
int *arr=SieveOfEratosthenes(10000);
while(t--){
cse+=1;
set<long> str;
int n=0;
int m=0;
cin>>m>>n;
long num[n];
long low[1][2];
low[0][0]=1000000;
int flag=0;
for (int i = 0; i < n; ++i)
{
long temp=0;
cin>>temp;
num[i]=temp;
if(temp<=low[0][0]){
low[0][0]=temp;
low[0][1]=i;
flag=i;
}

}
long pair[1][2];
for (int i = 0; i < 78499; ++i)
{
if(fmod(low[0][0],arr[i])==0){
pair[0][0]=arr[i];
pair[0][1]=low[0][0]/arr[i];
break;
}
}
//pair contains the decoded value at i
//pair may lie anywhere b/n the array so decode it both the ways
//to find the list of prime numbers
// cout<<"Decoded value at :"<<flag+1<<" "<<pair[0][0]<<"
"<<pair[0][1]<<endl;
//now create an array of 32 numbers
long res[n+1];
//curing the left sub array
long left=pair[0][0];
long right=pair[0][1];
if(fmod(num[flag+1],pair[0][0])==0){
long t=left;
left=right;
right=t;
}
res[flag+1]=right;
res[flag]=left;
// cout<<"\nFlags are: "<<left<<" "<<right<<endl;
// cout<<"Curing right of "<<flag<<endl;
for (int i = flag+1; i < n; ++i)
{
right=num[i]/right;
res[i+1]=right;
// cout<<res[i]<<endl;
}
// cout<<"\nCuring left of "<<flag<<endl;
for (int i = flag-1; i >-1; i--)
{
left=num[i]/left;
res[i]=left;
// cout<<res[i]<<endl;

}


// sort(res,res+n+1);
set<long> res2;
// cout<<"\nCured Array is:\n";
for (int i = 0; i < n+1; ++i)
{
// cout<<res[i]<<endl;
res2.insert(res[i]);
}
// cout<<"\nSorted Array is:\n";
set<long>::iterator itr;
map<long,char> mp;
int ch=65;
for (itr = res2.begin(); itr!=res2.end();itr++)
{
mp.insert(make_pair(*itr,(char)ch));
//cout<<*itr<<" -> "<<(char)ch<<"\n";
ch+=1;
}
cout<<"Case #"<<cse<<": ";
for (int i = 0; i < n+1; ++i)
{
auto it=mp.find(res[i]);
cout<<(*it).second;
}

cout<<endl;



}
return  0;
}

On Thu, Apr 11, 2019 at 12:21 AM F S <frederic.st...@gmail.com> wrote:

> On Monday, April 8, 2019 at 10:40:24 PM UTC+2, Abhishek Kalahal wrote:
> > RE means a runtime error happened, not an issue of time since the judge
> would've just said TLE (Time Limit Exceeded) if that was the case.
> >
> > My program probably would've gotten a TLE for the hidden test set but it
> shouldn't be an issue for the first set, where the highest valued prime
> wouldn't exceed 10,000.
> >
> > By the way Ralph, could you provide an example for the issue you stated?
> Were you referring to cases like ABA, where the first two numbers in the
> cipher text would be the same? I tried to account for that by including the
> statement "decipher = decipher [::-1]"
>
> First, your program prints something before the Case. This will make it
> fail.
>
> Second, your program doesn't work on:
>
> 1
> 107 29
> 15 15 15 15 21 49 77 143 221 323 437 667 899 1147 1517 1763 2021 2491 3127
> 3599 4087 4757 5183 5767 6557 7387 8633 9797 10403
>
> It outputs "CACACBFDIEMFRGSHTJUKVLWNXOYPZQ", while the correct answer is
> "ABABACCDEFGHIJKLMNOPQRSTUVWXYZ"
>
> --
> 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 google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/101677a3-8b4f-4e05-bca9-033646decca4%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAAQkXsM8hTPbgQ%2B2GmX-G_p3PWZN6NjF9pbx19yh-Tj%2B0qQsGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to