Skip to the content.

:heavy_check_mark: test/associative_array.test.cpp

Depends on

Code

#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"

#include <data_structure/hash_map.hpp>      // for HashMap
#include <fastio/base.hpp>                  // for cin, FASTIO, cout
#include <fastio/char/write.hpp>            // for operator<<
#include <fastio/signed/read.hpp>           // for operator>>
#include <fastio/unsigned/read.hpp>         // for operator>>
#include <fastio/unsigned/write.hpp>        // for operator<<
#include <templates/macro/abbrev/endl.hpp>  // for endl
#include <templates/macro/abbrev/ull.hpp>   // for ull
#include <templates/rep.hpp>                // for rep
#include <templates/template.hpp>
#include <version>  // for std
using namespace std;

int main() {
    int q;
    cin >> q;
    HashMap t;
    rep(_, q) {
        ull T, k;
        cin >> T >> k;
        if (T == 0) {
            ull v;
            cin >> v;
            t[k] = v;
        } else {
            cout << t[k] << endl;
        }
    }
}
#line 1 "test/associative_array.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"

#include <data_structure/hash_map.hpp>      // for HashMap
#include <fastio/base.hpp>                  // for cin, FASTIO, cout
#include <fastio/char/write.hpp>            // for operator<<
#include <fastio/signed/read.hpp>           // for operator>>
#include <fastio/unsigned/read.hpp>         // for operator>>
#include <fastio/unsigned/write.hpp>        // for operator<<
#include <templates/macro/abbrev/endl.hpp>  // for endl
#include <templates/macro/abbrev/ull.hpp>   // for ull
#include <templates/rep.hpp>                // for rep
#include <templates/template.hpp>
#include <version>  // for std
using namespace std;

int main() {
    int q;
    cin >> q;
    HashMap t;
    rep(_, q) {
        ull T, k;
        cin >> T >> k;
        if (T == 0) {
            ull v;
            cin >> v;
            t[k] = v;
        } else {
            cout << t[k] << endl;
        }
    }
}

Test cases

Env Name Status Elapsed Memory
g++ 2_powers_00 :heavy_check_mark: AC 147 ms 81 MB
g++ example_00 :heavy_check_mark: AC 5 ms 4 MB
g++ many_0set_00 :heavy_check_mark: AC 105 ms 40 MB
g++ many_0set_sparse_00 :heavy_check_mark: AC 29 ms 17 MB
g++ max_many_updates_00 :heavy_check_mark: AC 175 ms 88 MB
g++ max_random_00 :heavy_check_mark: AC 110 ms 44 MB
g++ max_random_01 :heavy_check_mark: AC 111 ms 44 MB
g++ max_random_02 :heavy_check_mark: AC 130 ms 53 MB
g++ py_killer_00 :heavy_check_mark: AC 117 ms 44 MB
g++ py_killer_01 :heavy_check_mark: AC 111 ms 44 MB
g++ random_00 :heavy_check_mark: AC 59 ms 27 MB
g++ random_01 :heavy_check_mark: AC 64 ms 28 MB
g++ random_02 :heavy_check_mark: AC 97 ms 48 MB
g++ sparse_keys_00 :heavy_check_mark: AC 32 ms 18 MB
g++ sparse_keys_01 :heavy_check_mark: AC 34 ms 21 MB
g++ unordered_map_killer_00 :heavy_check_mark: AC 184 ms 76 MB
g++ unordered_map_killer_01 :heavy_check_mark: AC 127 ms 76 MB
g++ unordered_map_killer_02 :heavy_check_mark: AC 149 ms 75 MB
Back to top page