Pagini recente » Cod sursa (job #3235936) | Cod sursa (job #2820391) | Cod sursa (job #2330284) | Cod sursa (job #977886) | Cod sursa (job #2107622)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
int w[1000000];
bool findx(int x, int i, char q[1000000] )
{cout<<w[999999]<<" ";
bool ok1=false, ok2=false;
for(int j=i-1; j>=0; j--)
{
if(w[j]==x)
{
if(q[j]=='1') {ok1=true; break;}
else if(q[j]=='2') {ok2=true; break;}
}
}
if(ok1 && !ok2) return true;
return false;
}
void read()
{
//int n;
fin>>n;
char q[n];
//int w[n];
int i=1;
while(fin>>q[i]>>w[i])
{
if(q[i]=='3') fout<<findx(w[i], i, q)<<'\n';
i++;
}
}
int main()
{
read();
}