Submission #1098263

#TimeUsernameProblemLanguageResultExecution timeMemory
1098263vjudge1Evacuation plan (IZhO18_plan)Pypy 2
0 / 100
21 ms19272 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; class UnionFind { public: vector<int> parent, rank; UnionFind(int n) { parent.resize(n); rank.resize(n, 0); for (int i = 0; i < n; ++i) parent[i] = i; } int find(int u) { if (parent[u] != u) parent[u] = find(parent[u]); return parent[u]; } void unionSets(int u, int v) { int root_u = find(u); int root_v = find(v); if (root_u != root_v) { if (rank[root_u] > rank[root_v]) parent[root_v] = root_u; else if (rank[root_u] < rank[root_v]) parent[root_u] = root_v; else { parent[root_v] = root_u; ++rank[root_u]; } } } }; int main() { int n, m; cin >> n >> m; vector<tuple<int, int, int>> bridges(m); for (int i = 0; i < m; ++i) { int u, v, d; cin >> u >> v >> d; bridges[i] = {d, u - 1, v - 1}; } int q; cin >> q; vector<pair<int, int>> queries; vector<pair<int, int>> updates; for (int i = 0; i < q; ++i) { int t; cin >> t; if (t == 1) { int b, r; cin >> b >> r; get<0>(bridges[b - 1]) = r; } else { int s, w; cin >> s >> w; queries.push_back({s - 1, w}); } } sort(bridges.rbegin(), bridges.rend()); for (auto [s, w] : queries) { UnionFind uf(n); for (auto [d, u, v] : bridges) { if (d <= w) uf.unionSets(u, v); } int reachable = 0; for (int i = 0; i < n; ++i) { if (uf.find(i) == uf.find(s)) ++reachable; } cout << reachable << endl; } return 0; }

Compilation message (stderr)

File "plan.py", line 4
    using namespace std;
          ^
SyntaxError: invalid syntax
#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...