# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
774782 | vjudge1 | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 8 ms | 5204 KiB |
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 main()
{
int n, x;
map<int,int>mp;
int a[200001], c[200001], b[200001], cnt;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=0;i<n;i++)
{
cin >> a[i];
}
for(int i=n-1;i>=0;i++)
{
if(mp[a[i]] == 0)
{
mp[a[i]] = i;
c[i] = i;
b[i] = i;
}
else
{
c[i] = i;
b[i] = mp[a[i]];
mp[a[i]] = i;
}
}
int p = 0;
bool ck = false;
while(p < n)
{
cnt = b[p] - c[p] + 1;
if(!ck)
{
for(int i=1;i<=cnt;i++)
{
cout << a[p] << endl;
}
}
else
{
for(int i=1;i<=cnt-1;i++)
{
cout << a[p] << endl;
}
}
p += cnt;
if(cnt > 1)
{
p -= 1;
ck = 1;
}
else
{
ck = false;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |