I disagree with this diagnosis. I think it faults with the large data set and gets the answer right if you make your array big enough.
A quick note: the 'break' breaks you out of the 'for (k = j + 1; k < p; k++)' loop, but not the 'for (j = 0; j < p - 1; j++)' loop. On Sat, Sep 5, 2015 at 7:47 AM, uDebug <[email protected]> wrote: > Hi, > > Your code seg faults with both kinds of input. > > Thanks, > > Vinit > > - - - - - > Check input and > accepted > output for over > 6 > *,000* problems on uDebug <http://www.udebug.com/>! > > Now including problems from* ACM-ICPC Live Archive* and *Google Code Jam* > ! > > > Find us on Facebook > <https://www.facebook.com/pages/Udebug/1458086424467115>. Follow us on > Twitter <https://twitter.com/uDebug>. > > On Sat, Sep 5, 2015 at 12:04 PM, yatingarg12 <[email protected]> > wrote: > >> # include <iostream> >> using namespace std; >> int main() >> {int n,c,p,a[100],x,y; >> cin>>n; >> for(int i=0;i<n;i++) >> {cin>>c>>p; >> for(int j=0;j<p;j++) >> {cin>>a[j];} >> for(int j=0;j<p-1;j++) >> for(int k=j+1;k<p;k++) >> {if(a[j]+a[k]==c){x=j+1;y=k+1; break;}} >> cout<<"Case #"<<i+1<<": "<<x<<" "<<y<<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/4842d4f2-732d-4490-8c6c-384d954da67a%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 [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/CA%2BXgmOU79UO%3DMHvgGz4uLMfnPBdxg_%3DquX0VR7u2%3DPTty_%2BTMw%40mail.gmail.com > <https://groups.google.com/d/msgid/google-code/CA%2BXgmOU79UO%3DMHvgGz4uLMfnPBdxg_%3DquX0VR7u2%3DPTty_%2BTMw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > 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 [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/CAECKw-PQ4EnqCrte5B0%2B78x3bscVg2Di4u4Rke4fAxr_TdiwmA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
