Submission #990880

#TimeUsernameProblemLanguageResultExecution timeMemory
990880tincamateiStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
203 ms16064 KiB
#include <bits/stdc++.h> int main() { int N; std::map<int, int> last_pos; std::vector<std::pair<int, int>> st; std::cin >> N; for (int i = 1; i <= N; i++) { int val; std::cin >> val; int last = i; if (last_pos[val] != 0) last = last_pos[val]; while (!st.empty() && st.back().first >= last) { last_pos[st.back().second] = 0; st.pop_back(); } st.push_back({last, val}); last_pos[val] = i; } std::vector<int> res(1 + N); int last = N; for (int t = (int)st.size() - 1; t >= 0; t--) { auto [first, val] = st[t]; while (last >= first) { res[last] = val; last--; } } for (int i = 1; i <= N; i++) std::cout << res[i] << "\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:33:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         auto [first, val] = st[t];
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...