Submission #864317

#TimeUsernameProblemLanguageResultExecution timeMemory
864317raphaelpSightseeing (NOI14_sightseeing)C++14
0 / 25
2079 ms102724 KiB
#include <bits/stdc++.h> using namespace std; int UF[500000]; int Rank[500000]; int num = 0; int find(int x) { return (x == UF[x]) ? x : (UF[x] = find(UF[x])); } bool merge(int a, int b) { a = find(a); b = find(b); if (a == b) return false; if (Rank[b] > Rank[a]) swap(a, b); UF[b] = a; if (Rank[b] == Rank[a]) Rank[a]++; num++; return true; } void rec(int x, int w, vector<vector<pair<int, int>>> &Tree, vector<int> &occ, vector<int> &Querries) { occ[x] = 1; if (Querries[x] == 1) Querries[x] = w; for (int i = 0; i < Tree[x].size(); i++) { if (occ[Tree[x][i].first] == 1) continue; rec(Tree[x][i].first, min(w, Tree[x][i].second), Tree, occ, Querries); } } void linsort(vector<tuple<int, int, int>> &Tab) { vector<vector<tuple<int, int, int>>> temp(100003); for (int i = 0; i < Tab.size(); i++) { temp[get<0>(Tab[i])].push_back(Tab[i]); } Tab.clear(); for (int i = 0; i < 100003; i++) { for (int j = 0; j < temp[i].size(); j++) { Tab.push_back(temp[i][j]); } } } int main() { int V, E, Q; cin >> V >> E >> Q; for (int i = 0; i < V; i++) { UF[i] = i; Rank[i] = 0; } vector<tuple<int, int, int>> Tab; for (int i = 0; i < E; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; Tab.push_back({c, a, b}); } linsort(Tab); }

Compilation message (stderr)

sightseeing.cpp: In function 'void rec(int, int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&, std::vector<int>&)':
sightseeing.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < Tree[x].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~
sightseeing.cpp: In function 'void linsort(std::vector<std::tuple<int, int, int> >&)':
sightseeing.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < Tab.size(); i++)
      |                     ~~^~~~~~~~~~~~
sightseeing.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int j = 0; j < temp[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...