結果
| 問題 |
No.8016 unordered_mapなるたけ落とすマン
|
| ユーザー |
|
| 提出日時 | 2016-05-22 15:12:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 86 ms / 1,000 ms |
| コード長 | 936 bytes |
| コンパイル時間 | 419 ms |
| コンパイル使用メモリ | 57,728 KB |
| 実行使用メモリ | 9,008 KB |
| 最終ジャッジ日時 | 2024-10-11 05:07:29 |
| 合計ジャッジ時間 | 6,085 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 |
ソースコード
#include <unordered_map>
#include <cstdio>
//本実装はboostによる.
namespace std{
template<typename T>
inline void hash_combine(size_t& seed, T const& v){
seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
template<typename It>
inline size_t hash_range(It first, It last){
size_t seed=0;
hash_range(seed,first,last);
return seed;
}
template<typename It>
inline void hash_range(size_t& seed, It first, It last){
for(;first!=last;++first)hash_combine(seed, *first);
}
template<typename A,typename B>
class hash<pair<A,B>>{
public:
size_t operator()(pair<A,B> const &p) const{
size_t seed=0;
hash_combine(seed,p.first);
hash_combine(seed,p.second);
return seed;
}
};
}
int main(){
int N,M;
long long x;
std::unordered_map<std::pair<long long,int>,int>m;
scanf("%d%d",&N,&M);
for(;N--;)scanf("%lld",&x),m[{x,0}]++;
for(;M--;)scanf("%lld",&x),printf(M?"%d ":"%d\n",m[{x,0}]);
}