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 <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <tuple>
int x, q;
int ret[100005];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
std::cin >> x >> q;
for (int i = 0; i < x; i++) {
ret[i] = 1000000000;
}
std::vector<std::tuple<int,int,int>> queries;
for (int i = 0, a, b, c; i < q; i++) {
std::cin >> a >> b >> c; --a, --b;
queries.emplace_back(a,b,c);
}
std::sort(queries.begin(),queries.end(),[](const std::tuple<int,int,int>& a, const std::tuple<int,int,int>& b) {
return std::get<2>(a) < std::get<2>(b);
});
for (const auto& [a, b, c] : queries) {
ret[a] = ret[b] = c;
}
for (int i = 0; i < x; i++) {
std::cout << ret[i] << " ";
}
std::cout << "\n";
}
# | 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... |