Cod sursa(job #2419169)

Utilizator potirasUAIC Borcan Andreea potiras Data 7 mai 2019 18:53:51
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.86 kb
#include <bits/stdc++.h>

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define DMAX 1
#define NMAX 1
#define p 105943

using namespace std;

int n, k, x, y,m,i,j,ans,op;
//string s;
vector<int> v[p];

int main()
{
	ifstream cin("hashuri.in");
	ofstream cout ("hashuri.out");
	ios_base::sync_with_stdio(false);
	cin>>n;
	size_t found;
	for (int i = 0; i < n; ++i)
	{
		cin>> op>>x;
		if(op==1)
		{
			v[x%p].push_back(x);
		}
		if(op==2)
		{
			v[x%p].erase(remove(v[x%p].begin(), v[x%p].end(),x), v[x%p].end());
		}
		if(op==3)
		{
			vector<int>::iterator it;
			j=x%p;
			it = find (v[j].begin(), v[j].end(), x);
			if (it != v[j].end())
			   cout << "1\n";
			 else
			   cout << "0\n";
		}
	}
}