結果
問題 | No.3016 unordered_mapなるたけ落とすマン |
ユーザー | Tlapesium |
提出日時 | 2020-08-16 18:03:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,519 bytes |
コンパイル時間 | 3,442 ms |
コンパイル使用メモリ | 223,488 KB |
実行使用メモリ | 15,668 KB |
最終ジャッジ日時 | 2024-10-11 10:36:32 |
合計ジャッジ時間 | 9,446 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,820 KB |
testcase_01 | AC | 5 ms
6,820 KB |
testcase_02 | AC | 4 ms
6,816 KB |
testcase_03 | AC | 51 ms
15,592 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 49 ms
15,532 KB |
testcase_07 | WA | - |
testcase_08 | AC | 49 ms
15,424 KB |
testcase_09 | AC | 51 ms
15,540 KB |
testcase_10 | WA | - |
testcase_11 | AC | 47 ms
15,592 KB |
testcase_12 | AC | 47 ms
15,588 KB |
testcase_13 | AC | 47 ms
15,456 KB |
testcase_14 | WA | - |
testcase_15 | AC | 47 ms
15,536 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 44 ms
15,532 KB |
testcase_19 | WA | - |
testcase_20 | AC | 46 ms
15,532 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 44 ms
15,476 KB |
testcase_25 | AC | 46 ms
15,384 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 45 ms
15,520 KB |
testcase_30 | WA | - |
testcase_31 | AC | 44 ms
15,448 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 44 ms
15,352 KB |
testcase_35 | AC | 43 ms
15,424 KB |
testcase_36 | AC | 44 ms
15,360 KB |
testcase_37 | WA | - |
testcase_38 | AC | 45 ms
15,444 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 4 ms
6,820 KB |
testcase_42 | AC | 3 ms
6,816 KB |
testcase_43 | AC | 4 ms
6,820 KB |
testcase_44 | AC | 7 ms
6,820 KB |
testcase_45 | AC | 6 ms
6,820 KB |
testcase_46 | AC | 6 ms
6,816 KB |
testcase_47 | AC | 34 ms
6,816 KB |
testcase_48 | AC | 34 ms
6,816 KB |
testcase_49 | AC | 36 ms
6,816 KB |
testcase_50 | AC | 40 ms
6,816 KB |
ソースコード
#pragma GCC optimize("O3") //#pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx2") #define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10) #include <bits/stdc++.h> constexpr int INF = 2147483647; constexpr long long int INF_LL = 9223372036854775807; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; using namespace std; typedef long long int ll; typedef unsigned long long int ull; template<typename keytype, typename valtype, typename Hasher = hash<keytype>, typename isEqual = equal_to<keytype>> struct HashMap { int bsize; // アドレスの数 int msize; // msize > dsize のときリハッシュする int dsize = 0; // データの数 int tombsize = 0; // 削除済みデータの数 struct container { // 0 -> empty 1 -> used 2 -> deleted int used = 0; pair<keytype, valtype> data; }; vector<container> varray; HashMap(int BucketSize = 100000) { bsize = 1 << (32 - __builtin_clz(BucketSize)); msize = bsize * 0.7; varray = vector<container>(bsize); } void resize(int nextsize) { auto tmp = varray; bsize = nextsize; msize = bsize * 0.7; dsize = 0; tombsize = 0; varray = vector<container>(bsize); for (int i = 0; i < tmp.size(); i++) { if (tmp[i].used != 1)continue; insert(tmp[i].data.first, tmp[i].data.second); } } valtype& insert(const keytype& a, const valtype& b) { if (dsize + 1 > msize)resize(bsize << 1); ull Hash = Hasher()(a); while (varray[Hash & (bsize - 1)].used != 0) { if (isEqual()(varray[Hash & (bsize - 1)].data.first, a)) return varray[Hash & (bsize - 1)].data.second; Hash++; } varray[Hash & (bsize - 1)] = { 1,{a,b} }; dsize++; return varray[Hash & (bsize - 1)].data.second; } void erase(const keytype& key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used != 1 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) throw "Not Found"; varray[Hash & (bsize - 1)].used = 2; tombsize++; } valtype& at(const keytype& key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used != 1 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) throw "Not Found"; return varray[Hash & (bsize - 1)].data.second; } valtype& operator[] (keytype key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used == 0) { if (dsize + 1 > msize)resize(bsize << 1); varray[Hash & (bsize - 1)].used = 1; varray[Hash & (bsize - 1)].data.first = key; dsize++; return varray[Hash & (bsize - 1)].data.second; } else if (varray[Hash & (bsize - 1)].used == 2 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) { if (dsize + 1 > msize)resize(bsize << 1); while (varray[Hash & (bsize - 1)].used != 0) Hash++; varray[Hash & (bsize - 1)].used = 1; varray[Hash & (bsize - 1)].data.first = key; dsize++; return varray[Hash & (bsize - 1)].data.second; } return varray[Hash & (bsize - 1)].data.second; } }; int main() { io_init; int N, M; cin >> N >> M; HashMap<ll, int> hm; for (int i = 0; i < N; i++) { ll tmp; cin >> tmp; hm[tmp]++; } for (int i = 0; i < M; i++) { ll tmp; cin >> tmp; cout << hm[tmp] << (i == M ? "\n" : " "); } }