Блог пользователя lyyllyyl

Автор lyyllyyl, история, 8 лет назад, По-английски

I was learning some builtin functions in STL. And I wrote these code.

#include <bits/stdc++.h>

int main() {
  std::deque<int> tmp{1, 2, 3};
  std::transform(tmp.begin(), tmp.end(), std::back_insert_iterator<std::deque<int>>(tmp), std::negate<>());
  std::copy(tmp.begin(), tmp.end(), std::ostream_iterator<int> (std::cout, "\n"));

  std::vector<int> now{1, 2, 3};
  std::transform(now.begin(), now.end(), std::back_insert_iterator<std::vector<int>>(now), std::negate<>());
  std::copy(now.begin(), now.end(), std::ostream_iterator<int> (std::cout, "\n"));
  return 0;
}

And I compile this code, with GCC 6.1.1, option -Wall -std=c++14. The the output of the code was:

1 2 3 -1 -2 -3 1 2 3 -1 0 -3

In my opinion, the 0 in the output should be -2. Am I wrong? If I use the back_insert_iterator wrong, please point it out. Thank you. If not, is this a bug for GCC 6.1.1? Feel free to compile this code on your own computer with different compiler and share your result. Thank you for the help. :)

UPD

I use the iterator wrong, push_back may cause relocation. CLOSED. Thank you again for the help.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

Автор lyyllyyl, история, 8 лет назад, По-английски

I want to find some (maybe all) submissions in codeforces status history. And I want to filter the submission by languages. For example, only submission in Haskell is listed. How can I do that? Please share you ideas. Thank you.

Here's some solutions I found right now.

  • In Gym, enter one contest, go to the status, hope some coders solved the problem in that specific languages. Search the submission by languages on the right window. Slow, Inefficient, I'm feeling lucky.
  • Chrome plugin: Codeforces Enhancer. Show languages of a contest in the standing by different colors. Click to show the target languages. Not efficient enough, I'm feeling lucky.
  • To be added...

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится