結果
| 問題 |
No.8016 unordered_mapなるたけ落とすマン
|
| ユーザー |
|
| 提出日時 | 2021-08-30 12:07:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,000 ms |
| コード長 | 3,299 bytes |
| コンパイル時間 | 2,023 ms |
| コンパイル使用メモリ | 197,112 KB |
| 最終ジャッジ日時 | 2025-01-24 04:04:25 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 |
ソースコード
#include <bits/stdc++.h>
using i8 = std::int8_t;
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using u128 = __uint128_t;
template<typename word>
static word Scanner() {
word x = 0, f = 1, c;
while (c = getchar_unlocked(), c < 48 || c > 57) if (c == 45) f = -f;
while (47 < c && c < 58) {
x = x * 10 + c - 48;
c = getchar_unlocked();
}
return f * x;
}
template<typename word>
static word ScannerUnsigned() {
word x = 0, c;
while (c = getchar_unlocked(), c < 48 || c > 57);
while (47 < c && c < 58) {
x = x * 10 + c - 48;
c = getchar_unlocked();
}
return x;
}
template<typename word>
static void Printer(word x) {
if (x < 0) {
putchar_unlocked('-');
x = -x;
}
if (x >= 10) {
Printer<word>(x / 10);
}
putchar_unlocked(x - x / 10 * 10 + 48);
}
template<typename word>
static void PrinterUnsigned(word x) {
if (x >= 10) {
PrinterUnsigned<word>(x / 10);
}
putchar_unlocked(x - x / 10 * 10 + 48);
}
static void newline() {
putchar_unlocked('\n');
}
template<typename word>
void print_vector(const std::vector<word>& v, word x = 0) {
int n = v.size();
for (int i = 0; i < n; i++) {
Printer<word>(v[i] + x);
if (i == n - 1) putchar_unlocked('\n');
else putchar_unlocked(' ');
}
}
template<typename word>
void println_vector(const std::vector<word>& v, word x = 0) {
int n = v.size();
for (int i = 0; i < n; i++) {
Printer<word>(v[i] + x);
newline();
}
}
static inline u64 ctz(u64 n) { return __builtin_ctzll(n); }
static inline u64 clz(u64 n) { return __builtin_clzll(n); }
static inline u64 popcnt(u64 n) { return __builtin_popcountll(n); }
u64 binary_gcd(u64 u, u64 v) {
int shl = 0;
while (u && v && u != v) {
bool eu = !(u & 1);
bool ev = !(v & 1);
if (eu && ev) {
++shl;
u >>= 1;
v >>= 1;
}
else if (eu && !ev) u >>= 1;
else if (!eu && ev) v >>= 1;
else if (u >= v) u = (u - v) >> 1;
else {
int tmp = u;
u = (v - u) >> 1;
v = tmp;
}
}
return !u ? v << shl : u << shl;
}
u64 binary_lcm(u64 u, u64 v) {
return u / binary_gcd(u, v) * v;
}
i32 ceil_pow2_32(i32 n) {
return n <= 1 ? 0 : 32 - __builtin_clz(n - 1);
}
i64 ceil_pow2_64(i64 n) {
return n <= 1 ? 0 : 64 - __builtin_clzl(n - 1);
}
static u64 _rng = 88172645463325252ULL;
u64 next_rand() {
_rng = _rng ^ (_rng << 7);
return _rng = _rng ^ (_rng >> 9);
}
template<typename T, i32 n, T z = T()>
class HashMap {
private:
std::array<std::vector<std::pair<u64, T>>, 1 << (n - 4)> v;
u32 hash(u64 a) const {
static constexpr u64 r = 11995408973635179863ULL;
return a * r >> (68 - n);
}
public:
T &operator[](u64 a) {
u32 i = hash(a);
for (auto &w : v[i]) if (w.first == a) return w.second;
v[i].emplace_back(a, z);
return v[i].back().second;
}
};
void Main() {
i32 n = Scanner<i32>();
i32 m = Scanner<i32>();
HashMap<u64, 17> hm;
for (i32 _ = 0; _ < n; _++) ++hm[ScannerUnsigned<u64>()];
for (i32 _ = 0; _ < m; _++) {
Printer<u64>(hm[Scanner<u64>()]);
putchar_unlocked((_ == m - 1) ? '\n' : ' ');
}
}
int main() {
Main();
return 0;
}