Cod sursa(job #2894516)

Utilizator Andreeamiruna27Mindrescu Andreea Andreeamiruna27 Data 27 aprilie 2022 22:15:04
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.81 kb
#include<bits/stdc++.h>
using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int p=700001;
int n;
vector<int>v[p];
void one(int x)
{
    for(auto i:v[x%p])
    {
        if(i==x) return;
    }
    v[x%p].push_back(x);
}

void two(int x)
{
    int i;
    for(i=0; i<(int)v[x%p].size(); i++)
    {
        if(x==v[x%p][i])
        {
            v[x%p].erase(v[x%p].begin()+i);
        }
    }
}

void three(int x)
{
    int i;
    for(i=0; i<v[x%p].size(); i++)
    {
        if(x==v[x%p][i])
        {
            g<<1<<'\n';
            return;
        }
    }
    g<<0<<'\n';
}

int main()
{
   int a, b, i;
   f>>n;
   for(i=1; i<=n; i++)
   {
       f>>a>>b;
       if(a==1)
           one(b);
       else
           if(a==2)
               two(b);
           else
               three(b);
   }

}