Cod sursa(job #2417198)

Utilizator Daria09Florea Daria Daria09 Data 29 aprilie 2019 10:27:34
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.22 kb
#include <bits/stdc++.h>
#define mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> a[mod+5];
int main()
{
    int n;
    f>>n;
    for(int i=1; i<=n; ++i)
    {
        int x,type;
        bool okay=false;
        f>>type>>x;
        if(type==1)
        {
            for(int i=0; i<a[x%mod].size(); ++i)
            {
                int y=a[x%mod][i];
                if(y==x)
                {
                    okay=true;
                    break;
                }
            }
            if(!okay)
                a[x%mod].push_back(x);
        }
        else if(type==2)
        {
            vector <int> aux;
            for(int i=0; i<a[x%mod].size(); ++i)
            {
                int y=a[x%mod][i];
                if(y!=x)
                    aux.push_back(y);
            }
            a[x%mod]=aux;
        }
        else
        {
            for(int i=0; i<a[x%mod].size(); ++i)
            {
                int y=a[x%mod][i];
                if(y==x)
                {
                    okay=true;
                    break;
                }
            }
            g<<okay<<'\n';
        }
    }
    return 0;
}