Pagini recente » Cod sursa (job #1345426) | Cod sursa (job #2370504) | Cod sursa (job #368858) | Cod sursa (job #1941978) | Cod sursa (job #1497220)
/*#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("sort.in");
ofstream fout("sort.out");
const int NMax = 100005;
int X[NMax],N;
int Y[NMax];
//INTERCLASARE
void Sort(int Left, int Right)
{
if(Left == Right)
return ;
int Mid = (Left+Right)/2;
Sort(Left,Mid);
Sort(Mid+1,Right);
int i = Left,j=Mid+1,k=Left;
while(i<=Mid && j<=Right)
{
if(X[i]<X[j])
Y[k++] = X[i++];
else
Y[k++] = X[j++];
}
while(i<=Mid)
{
Y[k++] = X[i++];
}
while(j<=Right)
{
Y[k++] = X[j++];
}
for(int i = Left ; i<=Right; i++)
{
X[i] = Y[i];
}
}
//QUICK SORT
int main()
{
//fin>>N;
while (!fin.eof())
{
fin>>X[N];
cout<<N<<' '<<X[N]<<'\n';
N++;
}
Sort(0,N-1);
for(int i=1; i<N; i++)
fout<<X[i]<<" ";
fout<<"n";
return 0;
}
*/
#include <fstream>
#include <algorithm>
#include <vector>
#define Rest 666013
using namespace std;
int n;
vector <int> Hashuri [Rest];
int main()
{
ifstream in ("hashuri.in");
ofstream out ("hashuri.out");
in>>n;
while (in>>n)
{
switch (n)
{
case 1:
{
in>>n;
if (find(Hashuri[n%Rest].begin(),Hashuri[n%Rest].end(),n)==Hashuri[n%Rest].end())
{
Hashuri[n%Rest].push_back(n);
}
}break;
case 2:
{
in>>n;
if (find(Hashuri[n%Rest].begin(),Hashuri[n%Rest].end(),n)!=Hashuri[n%Rest].end())
{
//vector<int>::iterator it;
//it=find(Hashuri[n%Rest].begin(),Hashuri[n%Rest].end(),n);
Hashuri[n%Rest].erase(find(Hashuri[n%Rest].begin(),Hashuri[n%Rest].end(),n)+1);
}
}break;
case 3:
{
in>>n;
if (find(Hashuri[n%Rest].begin(),Hashuri[n%Rest].end(),n)!=Hashuri[n%Rest].end())
{
out<<'1'<<'\n';
}
else
{
out<<'0'<<'\n';
}
}break;
}
}
return 0;
}