Cod sursa(job #2406006)

Utilizator alex2209alexPavel Alexandru alex2209alex Data 15 aprilie 2019 12:04:12
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
//-----------------------
//Variabile globale
int n,val[1000001];
vector<pair<int,pair<int,int>>>v;
//-----------------------
//Functii
void citeste();
void rezolva();
//-----------------------
int main()
{
	citeste();
	return 0;
}
//-----------------------
void rezolva()
{
	int last1;
	sort(v.begin(),v.end());
	for(int i = 0; i < v.size(); ++i)
	{
		if(v[i].first != v[i-1].first)
		{
			last1 = -1;
		}
		if(v[i].second.second == 1)
			last1 = 1;
		else if(v[i].second.second == 2)
			last1 = -1;
		else if(last1 == 1)
			val[v[i].second.first] = 1;
	}
}
//-----------------------
void citeste()
{
	int n;
	f >> n;
	for(int i = 1; i <= n; ++i)
	{
		int op,a;
		f >> op >> a;
		v.push_back({a,{i,op}});
	}
	rezolva();
	f.close();
	f.open("hashuri.in");
	f >> n;
	for(int i = 1; i <= n; ++i)
	{
		int op,a;
		f >> op >> a;
		if(op == 3)
			g << val[i] << '\n';
	}
}