This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"
#include "../../src/fnv1a.hpp"
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
using namespace std;
using lint = long long;
struct init {
init() {
cin.tie(nullptr); ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
}
} init_;
struct test {
lint i;
bool operator==(const test& r) const { return i == r.i; }
test(lint i) : i(i) {}
};
namespace std {
template<>
struct hash<test> {
uint64_t operator() (const test& t) const {
return fnv1a_64(to_string(t.i));
}
};
}
int main() {
int q;
cin >> q;
unordered_map<test, lint> mp;
for (int i = 0; i < q; i++) {
int t;
cin >> t;
if (t) {
lint k;
cin >> k;
cout << mp[test(k)] << "\n";
}
else {
lint k, v;
cin >> k >> v;
mp[test(k)] = v;
}
}
return 0;
}
#line 1 "test/yosupo/associative_array.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"
#line 2 "src/fnv1a.hpp"
#include <iostream>
using namespace std;
inline uint64_t fnv1a_64(const string& data) {
uint64_t hash = 0xcbf29ce484222325;
constexpr uint64_t prime = 0x100000001b3;
for (char i : data) {
hash = hash ^ i;
hash *= prime;
}
return hash;
}
#line 5 "test/yosupo/associative_array.test.cpp"
#line 7 "test/yosupo/associative_array.test.cpp"
#include <iomanip>
#include <string>
#include <unordered_map>
using namespace std;
using lint = long long;
struct init {
init() {
cin.tie(nullptr); ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
}
} init_;
struct test {
lint i;
bool operator==(const test& r) const { return i == r.i; }
test(lint i) : i(i) {}
};
namespace std {
template<>
struct hash<test> {
uint64_t operator() (const test& t) const {
return fnv1a_64(to_string(t.i));
}
};
}
int main() {
int q;
cin >> q;
unordered_map<test, lint> mp;
for (int i = 0; i < q; i++) {
int t;
cin >> t;
if (t) {
lint k;
cin >> k;
cout << mp[test(k)] << "\n";
}
else {
lint k, v;
cin >> k >> v;
mp[test(k)] = v;
}
}
return 0;
}