To Increment or Not to Increment
To Increment or Not to Increment S o, I re-did POJ 2352 (Stars) today, and got a time limit exceeded error. See the post earlier for a recap. I spent a hour debugging while loops, no luck. It's the only source of infinite loops, after all. ARRGGHH So, here's my code: #include <cstdio> using namespace std; int BIT[33001]; int ans[15001]; void incr(int ind) { while(ind<33000) { BIT[ind]++; ind += (ind&(-ind)); } } int get(int ind) { int res=0; while(ind) { res += BIT[ind]; ind -= (ind&(-ind)); } return res; } int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { int x, y; scanf("%d %d",&x, &y); ans[get(x)]++; incr(x); } for(int i=0;i<n;i++) printf("%d\n",ans[i]); } Ahem. See that disturbing red line over there? "No?" Maybe you're color blind. Okay. But anyways, this little monster here: ans[get(x)]++; Read that line ten times, then read th