Cod sursa(job #2976722)

Utilizator LukyenDracea Lucian Lukyen Data 9 februarie 2023 21:43:47
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.85 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

const int MOD = 967283;

vector<int> vec[MOD + 1];

int main()
{
  int n;
  fin >> n;

  int type, x;
  for (int i = 1; i <= n; i++)
  {
    fin >> type >> x;
    int hash = x % MOD;
    switch (type)
    {
    case 1:
      vec[hash].push_back(x);
      break;

    case 2:
      for (auto it = vec[hash].begin(); it != vec[hash].end(); it++)
        if (*it == x)
          vec[hash].erase(it), it--;
      break;

    case 3:
      bool found = false;
      for (auto it = vec[hash].begin(); it != vec[hash].end(); it++)
        if (*it == x)
        {
          found = true;
          break;
        }

      if (found)
        cout << "1\n";
      else
        cout << "0\n";
      break;
    }
  }

  return 0;
}