Cod sursa(job #2249438)
Utilizator | Emanuel Truta manutruta | Data | 29 septembrie 2018 21:12:54 |
---|---|---|---|
Problema | Hashuri | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.93 kb |
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define cout g
vector<int> v;
int main()
{
int t;
f >> t;
while (t)
{
t--;
int op, x;
f >> op >> x;
switch (op)
{
case 1:
{
v.push_back(x);
} break;
case 2:
{
vector<int>::iterator it = find(v.begin(), v.end(), x);
if (it != v.end())
{
*it = v[v.size() - 1];
v.pop_back();
}
} break;
case 3:
{
vector<int>::iterator it = find(v.begin(), v.end(), x);
cout << (it != v.end()) << '\n';
} break;
}
}
return 0;
}