rembocoder's blog

By rembocoder, history, 4 years ago, translation, In English

Hi. I want to share a simple method for coordinate compression. Even noob can write it.

vector<int> a(n);
// read the vector
vector<int> b = a;
sort(b.begin(), b.end());
map<int, int> m;
for (int i = 0; i < n; i++) {
    m[b[i]] = i;
}
for (int i = 0; i < n; i++) {
    a[i] = m[a[i]];
}

Now every value of an array lies in [0, n). The most convineint it that if you need the original value for a[i], you can just write b[a[i]].

And how do you write it?

Full text and comments »

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

By rembocoder, history, 4 years ago, translation, In English

In this thread it is shown how to go though all the submasks of a given mask without extra space or time. I needed to do the same thing for the overmasks, but I did not find anything. Based on the formula mask ^ (~mask) = -1, my brother gave me this code:

    for (int over = (1 << n) - 1; over > 0; over = ((over - mask - 1) & ~mask) + mask) {
        cout << over << " ";
    }

It really works. But can I simplify it, so it could be easier remembered during the contest?

Full text and comments »

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

By rembocoder, history, 6 years ago, In English

Did you see that #499 was made unrated? Is it a temporary thing or is it really unrated now? It would be very sad.

Full text and comments »

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

By rembocoder, history, 7 years ago, translation, In English

First I'll answer the question. In this season Sberbank payed for places in the hostel for participants. In the summer we notified the organisers that we want to go, but we decided on the team's line-up just recently. It turned out that the payed places are over, though we had a verbal agreement about us coming for the reduced price. I think it's not good to do so. Maybe it was a misunderstanding, but I became offended, so I will tell you about my impression of the first ride which was this winter.

That time our rector payed the fee, it was 1270 euro per person for 10 days. We were settled in a narrow hostel with wind blowing through the window, and it was quite cold then. As a result, everyone in our team got ill, and I had acute bronchitis for half a year. Settling for 10 days in that room costs 213 euro per person. We took breakfast in the hostel, for lunch they gave us the same burger every day, without any sauce and with raw meat, and a can of cola. There was no dinner. Suppose, that burger costed 3 euro, cola – 1 euro, for 10 days we get 40 euro. The remaining 1017 euro should have went for renting a room for contests, for lecturers' payment and for entertainment. Suppose, every lecturer got 1000 euro, there were no more than 10 of them, there were also about 100 participants, then everyone payed no more than 100 euro. We took part in the contests in a narrow place, which is not intented for this purposes. We brought our own laptops. According to their site, renting this place for 10 days costs about 30 euro per person. The enternainment was an excurcion to Sagrada Familia, which costs no more than 24 euro.

There is 863 euro (> 2/3 of the fee) left, and I know where they went. Not to mention the fact that this event had several large sponsors. I did not pay money, so I'm not complaining, but I want to bring this information to those who still invest in this. Think about whom you give your money to.

Full text and comments »

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

By rembocoder, 13 years ago, translation, In English
I suggest to enable to leave same comment in two languages (as well as with blogs now). You write first on english, then you press the button, switch to russian and write the translation, if you can.
If the user has chosen english language, then the comment is being displayed in english, if the user has chosen russian - in russian.

Full text and comments »

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