Submission #990769

#TimeUsernameProblemLanguageResultExecution timeMemory
990769xnqsLost Array (NOI19_lostarray)C++17
100 / 100
24 ms4036 KiB
#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 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...