Submission #683248

#TimeUsernameProblemLanguageResultExecution timeMemory
683248NursikBridges (APIO19_bridges)C++14
13 / 100
3068 ms30696 KiB
#include <stdio.h> #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define f first #define s second #define ld long double #define bug cout << "bug\n"; const ll maxn = 1e6 + 1, maxm = 2e2 + 1; const ll mod = 1e9 + 7, inf = 1e9, block = 550, hb = 126067, base = 1000050017, biginf = 5e18; const ld eps = 1e-15; using namespace std; int n, m, q; int u[maxn], v[maxn], d[maxn], used[maxn]; vector<pair<int, int>> g[maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; ++i){ cin >> u[i] >> v[i] >> d[i]; g[u[i]].pb(mp(v[i], i)); g[v[i]].pb(mp(u[i], i)); } cin >> q; for (int i = 1; i <= q; ++i){ int type; cin >> type; if (type == 1){ int x, y; cin >> x >> y; d[x] = y; } else{ int x, y; cin >> x >> y; for (int j = 1; j <= n; ++j){ used[j] = 0; } queue<int> q; q.push(x); used[x] = 1; while (q.size() > 0){ int v = q.front(); q.pop(); for (auto to : g[v]){ pair<int, int> nx = to; if (d[nx.s] >= y && used[nx.f] == 0){ used[nx.f] = 1; q.push(nx.f); } } } int ans = 0; for (int j = 1; j <= n; ++j){ ans += used[j]; } cout << ans << '\n'; } } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...