Submission #913905

# Submission time Handle Problem Language Result Execution time Memory
913905 2024-01-20T13:17:11 Z ReLice Stone Arranging 2 (JOI23_ho_t1) C++14
100 / 100
204 ms 38332 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
    ll i,j;
    ll n;
    cin>>n;
    vll v(n);
    map<ll,ll> mp;
    vector<ll> val;
    for(i=0;i<n;i++) {
        cin>>v[i];
        if(mp[v[i]]==0) val.pb(v[i]);
        mp[v[i]]++;
    }
    sort(all(val));
    for(i=0;i<n;i++){
        v[i]=lb(all(val),v[i])-val.begin();
    }

    vector<pair<ll,pair<ll,ll>>> ans;
    vector<vector<ll>> v2(n+5);
    for(i=0;i<n;i++){
        ll l=i,r=i;
        if(v2[v[i]].sz){
            while(ans.bc.fr!=v[i]){
                v2[ans.bc.fr].pob;
                ans.pob;
            }
            l=ans.bc.sc.fr;
            v2[ans.bc.fr].pob;
            ans.pob;
        }
        ans.pb({v[i],{l,r}});
        v2[v[i]].pb(i);
    }
    ll fin[n];
    while(ans.sz){
        for(i=ans.bc.sc.fr;i<=ans.bc.sc.sc;i++)fin[i]=ans.bc.fr;
        ans.pob;
    }
    for(i=0;i<n;i++) cout<<val[fin[i]]<<endl;
}

signed main(){
	start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 756 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 612 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 484 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 648 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 24 ms 9072 KB Output is correct
18 Correct 24 ms 9044 KB Output is correct
19 Correct 28 ms 9048 KB Output is correct
20 Correct 27 ms 8808 KB Output is correct
21 Correct 27 ms 9040 KB Output is correct
22 Correct 27 ms 9052 KB Output is correct
23 Correct 26 ms 8948 KB Output is correct
24 Correct 27 ms 9052 KB Output is correct
25 Correct 33 ms 9044 KB Output is correct
26 Correct 25 ms 9048 KB Output is correct
27 Correct 26 ms 9040 KB Output is correct
28 Correct 30 ms 8948 KB Output is correct
29 Correct 24 ms 9044 KB Output is correct
30 Correct 23 ms 9040 KB Output is correct
31 Correct 23 ms 9052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 756 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 612 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 484 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 648 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 456 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 24 ms 9072 KB Output is correct
48 Correct 24 ms 9044 KB Output is correct
49 Correct 28 ms 9048 KB Output is correct
50 Correct 27 ms 8808 KB Output is correct
51 Correct 27 ms 9040 KB Output is correct
52 Correct 27 ms 9052 KB Output is correct
53 Correct 26 ms 8948 KB Output is correct
54 Correct 27 ms 9052 KB Output is correct
55 Correct 33 ms 9044 KB Output is correct
56 Correct 25 ms 9048 KB Output is correct
57 Correct 26 ms 9040 KB Output is correct
58 Correct 30 ms 8948 KB Output is correct
59 Correct 24 ms 9044 KB Output is correct
60 Correct 23 ms 9040 KB Output is correct
61 Correct 23 ms 9052 KB Output is correct
62 Correct 35 ms 12108 KB Output is correct
63 Correct 188 ms 34672 KB Output is correct
64 Correct 191 ms 33732 KB Output is correct
65 Correct 36 ms 11732 KB Output is correct
66 Correct 36 ms 11732 KB Output is correct
67 Correct 37 ms 12116 KB Output is correct
68 Correct 39 ms 12124 KB Output is correct
69 Correct 37 ms 12116 KB Output is correct
70 Correct 37 ms 12112 KB Output is correct
71 Correct 38 ms 12108 KB Output is correct
72 Correct 39 ms 12112 KB Output is correct
73 Correct 138 ms 24388 KB Output is correct
74 Correct 133 ms 24512 KB Output is correct
75 Correct 200 ms 37784 KB Output is correct
76 Correct 186 ms 37560 KB Output is correct
77 Correct 204 ms 37476 KB Output is correct
78 Correct 192 ms 38332 KB Output is correct