結果

問題 No.8016 unordered_mapなるたけ落とすマン
ユーザー sntea
提出日時 2017-02-24 05:52:53
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 873 ms
コンパイル使用メモリ 171,748 KB
最終ジャッジ日時 2026-06-06 07:51:20
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/unordered_map.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/unordered_map:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:191,
                 from main.cpp:5:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/hashtable.h: In instantiation of 'class std::_Hashtable<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, MyHash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >':
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/unordered_map.h:115:18:   required from 'class std::unordered_map<long long int, int, MyHash>'
  115 |       _Hashtable _M_h;
      |                  ^~~~
main.cpp:65:31:   required from here
   65 |         unordered_map<LL,int,MyHash> mp;
      |                                      ^~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/hashtable.h:210:51: error: static assertion failed: hash function must be copy constructible
  210 |       static_assert(is_copy_constructible<_Hash>::value,
      |                                                   ^~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/hashtable.h:210:51: note: 'std::integral_constant<bool, false>::value' evaluates to false

ソースコード

diff #
raw source code

#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#else
	#define DEBUG(x) true
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define INF 1e8
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef pair<int,int> P;
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

class MyHash {
public:
	random_device rnd;
	int shift1 = rnd()%64;
	int shift2 = rnd()%64;
	int shift3 = rnd()%64;

	size_t operator()(LL x) const{
		x = x^(x<<shift1);
		x = x^(x>>shift2);
		x = x^(x<<shift3);
		return x;
	}
};

int main()
{
	ios_init();
	int n,m;
	cin >> n >> m;
	unordered_map<LL,int,MyHash> mp;
	REP(i,n){
		LL a;
		cin >> a;
		mp[a]++;
	}
	vector<int> ans(m);
	REP(i,m){
		LL b;
		cin >> b;
		ans[i] = mp[b];
	}
	pite(ALL(ans));
	return 0;
}
0