Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

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

I'm using mingw, gcc --version gives 5.3.0 on my windows 10 desktop. When I add the lines

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

and compile, it says

c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ext\pb_ds\hash_policy.hpp:610:78: fatal error: ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp: No such file or directory
compilation terminated.

I don't remember what it says on mac but it also doesn't work there. (I think mac is gcc 4.8 installed through homebrew.)

In the past I just used ubuntu vm to use the library, lol. But it is a bit of an annoyance.

Any tips?

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

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

You need to compile with gnu(https://gcc.gnu.org/). If you need only for codeforces, you can simply add this snippet to your code when you need to use unordered_map. I think this is the simplest solution.

#ifdef ONLINE_JUDGE

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

namespace mapOp {
    const int tmp = chrono::high_resolution_clock::now().time_since_epoch().count();

    template<class T> struct hsh {
        size_t operator()(const T& x) const { 
            return hash<T>{}(x)^tmp; // avoid anti-hash tests?
        }
    };

    template<class a, class b> using um = gp_hash_table<a,b,hsh<a>>;

    template<class a, class b> b get(um<a,b>& u, a x) {
        if (u.find(x) == u.end()) return 0;
        return u[x];
    }
}
using namespace mapOp;

#else

#define um unordered_map
template<class a, class b> b get(unordered_map<a,b>& u, a x) {
    if (u.find(x) == u.end()) return 0;
    return u[x];
}
#endif

um<int,int> used;

  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится -8 Проголосовать: не нравится

    Installation instructions on gcc website are super complicated. Is the only way to test locally the VM solution?

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Just had a doubt, can you please tell how to declare the variables of PBDS type ?

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

So I finally managed to do this in a better way on Windows. I used Windows Subsystem for Linux (the Ubuntu version), and now I test locally with no hassles, plus I can use unix commands.

In short, what you do is: you go to Windows settings, activate Windows Subsystem for Linux, then download whatever flavor you want from the Windows Store. Then just run that application, wait for it to install, install gcc, and you're done. Just navigate to /mnt/c/ to actually access your files on Windows and compile them. Then you'll be able to use these libraries with 0 issues.

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I have MinGW-G++ 6.3.0. There was the file named "hash_standard_resize_policy_imp.hpp0000644" in my case. I had success when renamed it to match the name of the missing one. Other way is to paste contents of "hash_policy.hpp" and replace the missing include with the contents of "hash_standard_resize_policy_imp.hpp0000644". In the end it looks like this (https://paste.ubuntu.com/p/zn8MFYPxtv/).

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thank you. Renaming has worked for me.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks <3 Renaming works for me.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    It worked.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot, renaming worked for me too.... :)

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot! This should be upvoted XDD

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot, man!!! Renaming worked. :)

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    IT worked .. i just replaced the file with hash_standard_resize_policy_imp.hpp and it worked. thanks

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks a lot. It worked:-)

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Renaming worked like a charm, I just renamed the file mentioned to hash_standard_resize_policy_imp.hpp and it worked. Thanks a lot

  • »
    »
    3 недели назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    This method worked for me

    steps: ( for windows )

    1. find MinGW folder in C drive ( or where you have installed it)

    2. search this string hash_standard_resize_policy_imp.hpp0000644 in search-bar of this folder

    3. rename by removing the numeric suffix from .hppXXXX to .hpp only

    4. save and run it

    Have a good day!!!

    • »
      »
      »
      46 часов назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      ty worked for me

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

for MacOS: brew install gcc is good enough

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    qingczha for macos <ext/pb_ds/assoc_container.hpp> worked fine for you after installing gcc or you did some extra steps, I did so many tries and added missing files but still doesn't work, I get so many random errors related to syntax in some files.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    even brew gcc does not recognise it. it also throws up error

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    Actually installing with brew works, but the command is not g++ but g++-v, being the 'v' the gcc version installed (in my case is g++-9). It seems that g++ is a reserved command or something on MacOS, but using an alias is possible to change the command from g++-v to g++ in the .bash_profile, check this link.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I think you have to specify the version of the GCC you are downloading. In my case

    "brew install gcc@10" worked for me. If I remember correctly it didn't work when I downloaded it by "brew install gcc"

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone please suggest a solution to this for windows??

»
4 года назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Has anyone used pbds in visual studio on windows ?if yes, how?

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Won't work. Visual Studio has a separate compiler. PBDS are extensions specific to g++ compiler. Install WSL and use the WSL terminal for compiling. Works nicely with VS Code (VS Code is NOT Visual Studio).

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Maybe you should try a newer version of gcc?

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

it seems does not work with the latest version of VSCode? I can include bits/stdc++.h but it can not recognize pbds headers. Any hints?