Cod sursa(job #2489465)

Utilizator Simon2712Simon Slanina Simon2712 Data 8 noiembrie 2019 20:03:42
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <vector>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
#define N 1000003
vector <int> v[N];
vector <int> v2;
int main()
{
    int n,i,tip,x,a,gas;
    cin>>n;
    for(i=1;i<=n;i++)
    {
      gas=-1;
      cin>>tip>>x;
      a=x%N;
      while(v[a].empty()==0)
      {
        if(v[a].front()==x)///yeeet
          gas=1;
        v2.push_back(v[a].front());
        v[a].pop_back();
      }
      while(v2.empty()==0)
      {
        if(!(v2.front()==a && tip==2))///nu trb scos
        v[a].push_back(v2.front());
        v2.pop_back();
      }
      if(tip==1)
      {
        if(gas==-1)
          v[a].push_back(x);
      }
      else
      if(tip==3)
        cout<<(gas==1)<<'\n';
    }
    return 0;
}