Cod sursa(job #1039106)

Utilizator gener.omerGener Omer gener.omer Data 22 noiembrie 2013 15:41:55
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.18 kb
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <iostream>
#include <bitset>

using namespace std;

#define INF (1<<29)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)

map<long long, int> m;

#define SIZE 512 * 1024
#define HASH_SIZE (SIZE * 8)

bitset<HASH_SIZE> all;

std::hash<unsigned long long> H;

int main()
{
  freopen("dtcsu.in", "rt", stdin);
  freopen("dtcsu.out", "wt", stdout);
  for(int i = 0; i < 276997; ++i){
    long long x;
    cin >> x;
    m[x] = 1;
    int p = H(x) % HASH_SIZE;
    all.set(p);
  }

  long long n;
  cin >> n;
  int ret = 0;
  for(int i = 0; i < n; ++i)
  {
    long long x;
    cin >> x;
    int p = H(x) % HASH_SIZE;
    if(all[p])
      if(m.find(x) != m.end())
        ++ret;
  }

  cout << ret;

  return 0;
}