Submission #1104278

#TimeUsernameProblemLanguageResultExecution timeMemory
1104278overwatch9Lost Array (NOI19_lostarray)C++17
26 / 100
64 ms6324 KiB
#include <bits/stdc++.h> using namespace std; bool comp(array <int, 3> a, array <int, 3> b) { return a[2] < b[2]; } int main() { int n, m; cin >> n >> m; map <int, multiset <int>> mp; vector <array <int, 3>> nums(m); for (int i = 0; i < m; i++) { cin >> nums[i][0] >> nums[i][1] >> nums[i][2]; mp[nums[i][0]].insert(nums[i][2]); mp[nums[i][1]].insert(nums[i][2]); } vector <int> ans(n+1); sort(nums.begin(), nums.end(), comp); for (int i = 0; i < m; i++) { int a = nums[i][0], b = nums[i][1], c = nums[i][2]; if (ans[a] == 0) ans[a] = c; if (ans[b] == 0) ans[b] = c; if (*mp[a].begin() == c) ans[a] = c; else ans[b] = c; mp[a].erase(mp[a].find(c)); mp[b].erase(mp[b].find(c)); } for (int i = 1; i <= n; i++) cout << ans[i] << ' '; 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...