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 <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
map<int, vector<int>> indexes;
vector<pair<int, int>> results;
int main()
{
// freopen("inp.txt", "r", stdin);
ios::sync_with_stdio(false);
cin >> n;
v.resize(n + 1);
for (int i = 1; i <= n; i++)
{
cin >> v[i];
indexes[v[i]].push_back(i);
}
for (int i = 1; i <= n;)
{
auto p = &indexes[v[i]];
auto itr = ++lower_bound(p->begin(), p->end(), i);
if (itr != p->end())
{
results.emplace_back(*itr - i + 1, v[i]);
i = *itr + 1;
}
else
{
results.emplace_back(1, v[i]);
i++;
}
}
for (auto &result : results)
for (int i = 0; i < result.first; i++)
cout << result.second << '\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... |