Cod sursa(job #2617536)

Utilizator Sobolanul_InvartitSob Trob Sobolanul_Invartit Data 21 mai 2020 22:08:27
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
	
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int a=666020;
const int nrp=666013;
 
vector<int> v2[a];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
 
void searchv(int x,int op){
    for(int i=0;i<v2[x%nrp].size();i++){
        if(v2[x%nrp][i]==x){
            if(op==1)return;
            else if(op==2){
                v2[x%nrp].erase(v2[x%nrp].begin()+i);
                return;
            }
            else {g<<1<<"\n";return;}
        }
    }
    if(op==1){
    v2[x%nrp].push_back(x);
    return;}
    else if(op==2)return ;
    else {g<<0<<"\n";return;}
}
 
int main()
{
    int n,op,nr;
    f>>n;
    for(int i=1;i<=n;i++){
        f>>op>>nr;
        searchv(nr,op);
    }
    return 0;
}