Cod sursa(job #886750)

Utilizator SPDionisSpinei Dionis SPDionis Data 23 februarie 2013 11:04:36
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include <fstream>
#include <map>

using std::map;

std::ifstream in("hashuri.in");
std::ofstream out("hashuri.out");

void op1(int x, map<int,int>& a)
{
    if ( a[x] == 0 ) a[x] = 1;
}

void op2 (int x, map<int,int>& a)
{
    if ( a[x] == 1 ) a[x] = 0;
}

int op3 (int x, map<int,int>& a)
{
    if ( a[x] == 1 ) return 1;
    else return 0;
}



int main()
{
    int n;
    in >> n;
    map<int, int> ab;


    for (int i = 0; i < n; ++i)
        {
            int a,b;
            in >> a >> b;
            if ( a == 1 ) op1(b, ab);
            else if ( a == 2 ) op2(b, ab);
            else if ( a == 3 ) out << op3(b, ab) << '\n';
        }

    in.close();
    out.close();
    return 0;
}