Submission #1039806

#TimeUsernameProblemLanguageResultExecution timeMemory
1039806ymmStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
1714 ms14672 KiB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 200'010;

int a[N];
map<int, int> last;

__attribute__((optimize("O3,unroll-loops"), target("avx2,prefer-vector-width=128")))
void myfill(int l, int r, int x)
{
	Loop (i,l,r)
		a[i] = x;
}

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n;
	cin >> n;
	Loop (i,0,n) {
		cin >> a[i];
		if (auto it = last.find(a[i]); it == last.end() || a[it->second] != a[i])
			last[a[i]] = i;
		myfill(last[a[i]], i, a[i]);
	}
	Loop (i,0,n)
		cout << a[i] << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...