Cod sursa(job #1144321)

Utilizator nimicLeoveanu Mihaita Alexandru nimic Data 16 martie 2014 21:54:30
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.83 kb
#include<fstream>
#include<vector>
using namespace std;
ifstream in( "hashuri.in" );
ofstream out( "hashuri.out" );
 
const int mod = 666013;
vector <int> has[mod];
int p, x, n, key, j;
bool avem;
 
int main()
{
	int player_unu=0;

    in>>n;
    for(int i = 0; i < n; i++)
	{
        in>>p>>x;
        key = x % mod;
        for(j = 0; j<(int)has[key].size(); j++)
		{
            if(has[key][j]==x)
			{
                avem = 1;
                break;
            }
        }

        if(p==1 && avem==0)
		{
            has[key].push_back(x);
        }

		if (p==2 && avem==1)
		{
            has[key][j] = has[key][has[key].size() - 1];
            has[key].resize(has[key].size() - 1);
        }

		if (p==3)
		{
            out<<avem<<'\n';
        }

		avem = 0;
    }

  return player_unu;
}