Submission #770219

#TimeUsernameProblemLanguageResultExecution timeMemory
770219script_kiddStone Arranging 2 (JOI23_ho_t1)C++14
0 / 100
4 ms5076 KiB
#include<bits/stdc++.h>
//#define int long long
using namespace std;
using pii=pair<int, int>;
using vi=vector<int>;
using vvi=vector<vector<int>>;

//using ll=long long;

#define loop(x,n) for(int x=0; x<n; x++)
#define loop1(x,n) for(int x=1; x<=n; x++)
#define loopr(x,n) for(int x=n; x-->0;)

#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define all(v) begin(v), end(v)
#define UNTIE_IO ios_base::sync_with_stdio(0);cin.tie(0);

const int MAX=2e5+5;
const int INF=2e9;
const int MOD=998244353;

int N;
pii _c[MAX];
int c[MAX];
vector<int> p[MAX];


void solve(){
    vector<int> v;
    int lt;
    loop1(i, N){
        if (p[c[i]].size()){
            lt = p[c[i]].back();
            while (v.size()&&c[v.back()]!=c[i]){
                p[c[v.back()]].pop_back();
                v.pop_back();
            }
        }
        p[c[i]].pb(i);
        v.pb(i);
    }
    int idx=0;
    loop1(i, N){
        if (i>v[idx]) idx++;
        cout << c[v[idx]] << '\n';
    }
}

signed main(){
    UNTIE_IO;
    cin>>N;

    int x;
    loop1(i, N){
        cin>>x;
        _c[i] = mp(x, i);
    }
    sort(_c+1, _c+1+N);


    int lt=-1, idx=0;
    loop1(i, N){
        if (lt!=_c[i].first){
            idx++;
            lt = _c[i].first;
        }
        c[_c[i].second] = idx;
    }
    solve();
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:34:9: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   34 |     int lt;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...