Pagini recente » Cod sursa (job #1576093) | Cod sursa (job #1485637) | Cod sursa (job #1635462) | Cod sursa (job #542052) | Cod sursa (job #3341535)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("marbles.in");
ofstream fout("marbles.out");
const int nmax = 1e5+2;
set<int> bile[65];
unordered_map<int, int> culoare;
int n, m;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(nullptr);
fin>>n>>m;
for(int i = 1; i <= n; ++i)
{
int x, c;
fin>>x>>c;
culoare[x] = c;
bile[c].insert(x);
}
while(m--)
{
int tip, i, j;
fin>>tip>>i>>j;
if(tip == 0)
{
int c = culoare[i];
bile[c].erase(i);
bile[c].insert(i+j);
culoare.erase(i);
culoare[i+j] = c;
}
else
{
int maxi = 0;
for(int b = 1; b <= 64; ++b)
{
auto st = bile[b].lower_bound(i);
auto dr = bile[b].upper_bound(j);
int nrb = distance(st, dr);
maxi = max(maxi, nrb);
}
fout<<maxi<<"\n";
}
}
return 0;
}