Pagini recente » Cod sursa (job #1332872) | Cod sursa (job #2443779) | Cod sursa (job #974016) | Cod sursa (job #1769354) | Cod sursa (job #390355)
Cod sursa(job #390355)
// hash.cpp
//
// Copyright 2010 SpeeDemon <virtualdemon@ubuntu>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
#include <list>
#include <fstream>
#include <algorithm>
#define Modulo 766021
/*
*
*/
using namespace std;
list< int > L[Modulo];
int main()
{
int n, x, y, pos;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
in>>n;
for( ; n; --n )
{
in>>x>>y;
pos=y%Modulo;
switch( x )
{
case 1 : L[pos].push_back(y); break;
case 2 : L[pos].remove(y); break;
case 3 : out<<( L[pos].end() != find( L[pos].begin(), L[pos].end(), y ) )<<'\n'; break;
}
}
return 0;
}