Pagini recente » Cod sursa (job #1299717) | Cod sursa (job #135039) | Cod sursa (job #3385) | Cod sursa (job #87925) | Cod sursa (job #2847628)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("marbles.in");
ofstream fout("marbles.out");
int n, m, col_max;
int len[65];
vector<int> L[65];
int culoare[100003];
void Citire()
{
int i, x, color;
fin >> n >> m;
for (i = 1; i <= n; i++)
{
fin >> x >> color;
L[color].push_back(x);
col_max = max(col_max, color);
}
}
int CB_main(int x, int C)
{
int st, dr, mij;
st = 0; dr = L[C].size() - 1;
while (st <= dr)
{
mij = (st + dr) / 2;
if (x == L[C][mij]) return mij;
else if (x > L[C][mij]) st = mij + 1;
else dr = mij - 1;
}
return -1;
}
int IterareCulori(int x)
{
int i, y;
for (i = 1; i <= col_max; i++)
{
y = CB_main(x, i);
if (y != -1) // elementul de pe pozitia x apartine vectorului de culoare y
return y;
}
}
int CB_stanga(int x, int C)
{
}
void IntervalCuloareMaxima()
{
int i, x, y;
for (i = 1; i <= col_max; i++)
{
x = CB_stanga();
//y = CB_dreapta();
}
}
void Rezolva()
{
int i, x, y, q;
for (i = 1; i <= col_max; i++)
sort(L[i].begin(), L[i].end());
for (i = 1; i <= m; i++)
{
fin >> q >> x >> y;
if (q == 0)
L[i][IterareCulori(x)] = x + y;
else
IntervalCuloareMaxima();
}
}
int main()
{
Citire();
Rezolva();
fin.close();
fout.close();
return 0;
}