Submission #1180044

#TimeUsernameProblemLanguageResultExecution timeMemory
1180044bbartekStone Arranging 2 (JOI23_ho_t1)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define st first #define nd second #define pb push_back const int maxn = 2e5+7; int liczby[maxn]; map<int,int> lewy,prawy; map<int,bool> usuniete; int wynik[maxn]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int a; for(int i=1;i<=n;i++){ cin>>a; liczby[i] = a; if(prawy[a] != 0){ lewy[a] = prawy[a]; prawy[a] = i; } else if(lewy[a] != 0){ prawy[a] = i; } else{ lewy[a] = i; } } queue<int> Q; for(int i=n;i>=1;i--){ if(i == prawy[liczby[i]]){ Q.push(liczby[i]); } if(lewy[liczby[i]] == i){ usuniete[liczby[i]] = 1; } wynik[i] = Q.front(); while(usuniete[Q.front()]) Q.pop(); } for(int i=1;i<=n;i++){ cout<<wynik[i]<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...