# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433804 | JeanBombeur | Bridges (APIO19_bridges) | C++17 | 3090 ms | 7056 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
// <|°_°|>
const int MAX_NOEUDS = (50 * 1000);
vector <int> Voisins[MAX_NOEUDS];
pair <int, int> Aretes[4 * MAX_NOEUDS];
bool Vu[MAX_NOEUDS];
int nbNoeuds, nbAretes, nbRequetes;
void Clear() {
fill_n(Vu, nbNoeuds, false);
return;
}
int Count(int noeud, int val) {
int sum = 1;
Vu[noeud] = true;
for (int id : Voisins[noeud])
{
if (!Vu[Aretes[id].first] && Aretes[id].second >= val)
sum += Count(Aretes[id].first, val);
}
return sum;
}
void Read() {
scanf("%d %d", &nbNoeuds, &nbAretes);
for (int i = 0; i < nbAretes; i ++)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
Voisins[-- a].push_back(2 * i);
Voisins[-- b].push_back(2 * i + 1);
Aretes[2 * i] = {b, c};
Aretes[2 * i + 1] = {a, c};
}
return;
}
void Solve() {
scanf("%d", &nbRequetes);
for (int i = 0; i < nbRequetes; i ++)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
b --;
if (a == 1)
Aretes[2 * b].second = Aretes[2 * b + 1].second = c;
else
{
printf("%d\n", Count(b, c));
Clear();
}
}
return;
}
int main() {
Read();
Solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |