Submission #1342514

#TimeUsernameProblemLanguageResultExecution timeMemory
1342514makskusStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
63 ms12800 KiB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#include <climits>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <functional>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <random>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(a,b) for(int a = 0;a<b;a++)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(),a.end()
const int inf = 1e9;
const ll infl = 1e18;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;

    //indeksujemy od 1
    vector<ll> a(n+1);
    rep(i, n){
        cin >> a[i+1];
    }

    unordered_map<int, int> ost_wyst;
    rep(i, n){
        ost_wyst[a[i+1]] = i+1;
    }   

    int ind = 1;
    while(ind <= n){
        if(ost_wyst[a[ind]]!=0){
            int d = ost_wyst[a[ind]] - ind + 1;
            rep(i, d){
                cout << a[ind] << "\n";
            }
            ind += d;
        }
        else{
            cout << a[ind] << "\n";
            ind++;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...