結果

問題 No.8016 unordered_mapなるたけ落とすマン
ユーザー pekempey
提出日時 2016-05-22 00:54:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 166,144 KB
実行使用メモリ 9,648 KB
最終ジャッジ日時 2024-10-07 05:56:41
合計ジャッジ時間 7,212 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |                 scanf("%lld", &a);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                 scanf("%lld", &b);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

unsigned xor_shift(unsigned x) {
	static unsigned y = time(NULL);
	x ^= y; x ^= x << 13; x ^= x >> 7; x ^= x << 17;
	return x;
}

struct Hash {
	size_t operator()(const long long &x) const {
		return xor_shift(hash<long long>()(x));
	}
};

int main() {
	int n, m;
	cin >> n >> m;

	unordered_map<long long, int, Hash> mp;
	for (int i = 0; i < n; i++) {
		long long a;
		scanf("%lld", &a);
		mp[xor_shift(a)]++;
	}
	for (int i = 0; i < m; i++) {
		long long b;
		scanf("%lld", &b);
		printf("%d ", mp[xor_shift(b)]);
	}

	cout << endl;
}
0