Re: [algogeeks] help me reduce the time limit
use segment tree http://en.wikipedia.org/wiki/Segment_tree -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] help me reduce the time limit
please help mewritea program for this problem to reduce the time limit http://www.codechef.com/problems/FLIPCOIN/ thnx in advance i have ben banging my head on this for a full day -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] help me reduce the time limit
see TC forums : On Wed, Dec 8, 2010 at 10:44 PM, ankit sablok ankit4...@gmail.com wrote: please help mewritea program for this problem to reduce the time limit http://www.codechef.com/problems/FLIPCOIN/ thnx in advance i have ben banging my head on this for a full day -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] help me reduce the time limit
#includestdio.h int main() { int arr[11]={0},sum2[1001]={0}; int type[1001]={0};//0 for tails int N,Q,i,j,sum; int a,b,c; scanf(%d,N); scanf(%d,Q); for(i=0;iQ;i++) { scanf(%d%d%d,a,b,c); if(a==0) { j=b; int k=j/100; while(j%100 j=c) { if(arr[j]) { arr[j]=!arr[j]; sum2[k]--; } else{ arr[j]=!arr[j]; sum2[k]++; } j++; } while(j+100=c) { type[j/100]=!type[j/100]; j+=100; } k=j/100; while(j=c) { if(arr[j]) { arr[j]=!arr[j]; sum2[k]--; } else{ arr[j]=!arr[j]; sum2[k]++; } j++; } } else{ sum=0; j=b; int k=j/100; while(j%100 j=c) { sum+=arr[j]^type[k]; j++; } while(j+100=c) { if(type[j/100]) sum+=100-sum2[j/100]; else sum+=sum2[j/100]; j+=100; } k=j/100; while(j=c) { sum+=arr[j]^type[k]; j++; } printf(%d\n,sum); } } return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.