sonjoydabnath's blog

By sonjoydabnath, history, 9 years ago, In English

So? This is actually a feature request!

It happens sometimes that I 've found a problem on CF and right now I am busy with my exam preparation or just I have no time right now to solve this problem. But I wish to solve this problem later because the problem is so interesting to me. But Unfortunately sometimes I lost the problem and can't remember the problem id/link :( .

In this case isn't it helpful to have "My To Do List" of problems where I can find those problems which I 've previously marked as interesting/added in my to do list and I wished to solve it later? This list could be private, only I can see the list in my profile. And whenever I solve a problem from my to do list it will automatically removed from my to do list.

I think it will be helpful for lots of people. Though I know I can keep those problems in my browser as bookmarks but I think rather than keeping a lot of bookmarks of problems, this To Do List could do better.

This feature already we can see in Codechef

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it

By sonjoydabnath, history, 9 years ago, In English

Today I tried to solve Problem D(div2) of last Contest ( Codeforces Round 310 (Div. 2) ). In this problem I used lower_bound() function on a set of pair of pair and int ( set< pair< pair<long long, long long> , int > > ). Here is my ACed submission 11834954 and my TLE submission 11835029 . I don't know why I get TLE in second code. :S

Ok, Let me explain what I 've done here, I have a set like set< pair< pair<long long, long long> , int > > bridges on which I tried to apply lower_bound() function ( in line number 171 in my both code ). In first submission I used lower_bound() as like bridges.lower_bound(make_pair(keyValue,0LL)) and I got AC. But in my second code I used lower_bound() as like lower_bound(bridges.begin(),bridges.end(),make_pair(keyValue,0LL)) and I got TLE on case 11.

What is the difference between calling lower_bound() function in above mentioned 2 way ?

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By sonjoydabnath, 10 years ago, In English

While looking for how other people solved the problem I see a solution (1620364) of 182D - Общие делители by RAD . In this solution He tried to initialize and access a negative index of a Array! I 've always known that it's not possible. Can anybody explain me how he did this or, how negative index working on an Array ?

A significant part of RAD's code:


void calc_hash(const string &s, int64 *&h) { h = new int64[110000] + 1; h[-1] = 0; //initiating a negative index with a value of 0!! forn(i, s.size()) h[i] = h[i - 1] * 313 + s[i]; } ......... ...... .... . ... //code snippet from the main function int ans = 0; for (int len = min((int)s1.size(), (int)s2.size()); len >= 1; len--) if (s1.size() % len == 0 && s2.size() % len == 0) { int64 ha = h1[len - 1]; for (int i = len - 1; i < (int)s1.size(); i += len) if (h1[i] - h1[i - len] * pw[len] != ha) //here i-len sometimes could be negative, goto bad; //but it's Not giving RTE :O for (int i = len - 1; i < (int)s2.size(); i += len) if (h2[i] - h2[i - len] * pw[len] != ha) goto bad; ans++; bad:; } cout << ans << endl;

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it