Submission #556719

# Submission time Handle Problem Language Result Execution time Memory
556719 2022-05-03T18:39:22 Z new_acc Volontiranje (COCI21_volontiranje) C++14
50 / 110
511 ms 138576 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<20;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N],num[N],seg2[N],dp[N];
vi seg[N],pom[N],c;
bool dg=0;
void upd(int a,int b){
    for(a+=SS;a>0;a>>=1) seg2[a]=max(seg2[a],b);
}
int Query(int a,int b){
    int res=0;
    for(a+=SS-1,b+=SS+1;(a>>1)!=(b>>1);a>>=1,b>>=1){
        if(!(a&1)) res=max(res,seg2[a+1]);
        if(b&1) res=max(res,seg2[b-1]);
    }
    return res;
}
void upd2(int x,int a,int b){
    a+=num[x],seg[x][a]=b;
    for(a>>=1;a>0;a>>=1) seg[x][a]=min(seg[x][(a<<1)],seg[x][(a<<1)+1]);
}
int Query2(int curr,int x,int v=1){
    if(v>num[curr]) return v-num[curr];
    if(seg[curr][(v<<1)+1]<=x) return Query2(curr,x,(v<<1)+1);
    else return Query2(curr,x,(v<<1));
}
int rek(int curr,int ind){
    if(curr==0) return 1;
    int q=Query2(curr,ind);
    while(seg[curr][1]<ind and t[ind]>t[pom[curr][q-1]] and rek(curr-1,pom[curr][q-1])==-1){
        upd2(curr,q,INFi);
        q=Query2(curr,ind);
    } 
    if(seg[curr][1]>ind or t[ind]<t[pom[curr][q-1]]) return -1;
    c.push_back(pom[curr][q-1]);
    upd2(curr,q,INFi);
    return 1;
}
void solve(){
    int n,maxi=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i];
        dp[i]=Query(1,t[i])+1;
        upd(t[i],dp[i]);
        pom[dp[i]].push_back(i);
        maxi=max(maxi,dp[i]);
    }
    t[n+1]=n+1;
    for(int i=1;i<=maxi;i++){
        int curr=1;
        while(curr<=pom[i].size()) curr<<=1;
        for(int k=1;k<=(curr<<1)+5;k++) seg[i].push_back(INFi);
        num[i]=curr;
        for(int j=0;j<pom[i].size();j++) upd2(i,j+1,pom[i][j]);
    }
    vector<vi>ans;
    while(rek(maxi,n+1)>0) ans.push_back(c),c.clear();
    cout<<ans.size()<<" "<<maxi<<"\n";
    for(auto u:ans){
        for(auto xd:u) cout<<xd<<" ";
        cout<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:68:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         while(curr<=pom[i].size()) curr<<=1;
      |               ~~~~^~~~~~~~~~~~~~~
Main.cpp:71:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for(int j=0;j<pom[i].size();j++) upd2(i,j+1,pom[i][j]);
      |                     ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 47300 KB Output is correct
2 Correct 22 ms 47268 KB Output is correct
3 Correct 25 ms 47316 KB Output is correct
4 Correct 23 ms 47340 KB Output is correct
5 Correct 23 ms 47296 KB Output is correct
6 Correct 23 ms 47312 KB Output is correct
7 Correct 23 ms 47316 KB Output is correct
8 Correct 22 ms 47316 KB Output is correct
9 Correct 22 ms 47288 KB Output is correct
10 Correct 22 ms 47368 KB Output is correct
11 Correct 22 ms 47284 KB Output is correct
12 Correct 22 ms 47316 KB Output is correct
13 Correct 22 ms 47248 KB Output is correct
14 Correct 22 ms 47304 KB Output is correct
15 Correct 28 ms 47264 KB Output is correct
16 Correct 27 ms 47356 KB Output is correct
17 Correct 24 ms 47368 KB Output is correct
18 Correct 26 ms 47308 KB Output is correct
19 Correct 28 ms 47288 KB Output is correct
20 Correct 22 ms 47320 KB Output is correct
21 Correct 23 ms 47260 KB Output is correct
22 Correct 22 ms 47256 KB Output is correct
23 Correct 22 ms 47316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 47300 KB Output is correct
2 Correct 22 ms 47268 KB Output is correct
3 Correct 25 ms 47316 KB Output is correct
4 Correct 23 ms 47340 KB Output is correct
5 Correct 23 ms 47296 KB Output is correct
6 Correct 23 ms 47312 KB Output is correct
7 Correct 23 ms 47316 KB Output is correct
8 Correct 22 ms 47316 KB Output is correct
9 Correct 22 ms 47288 KB Output is correct
10 Correct 22 ms 47368 KB Output is correct
11 Correct 22 ms 47284 KB Output is correct
12 Correct 22 ms 47316 KB Output is correct
13 Correct 22 ms 47248 KB Output is correct
14 Correct 22 ms 47304 KB Output is correct
15 Correct 28 ms 47264 KB Output is correct
16 Correct 27 ms 47356 KB Output is correct
17 Correct 24 ms 47368 KB Output is correct
18 Correct 26 ms 47308 KB Output is correct
19 Correct 28 ms 47288 KB Output is correct
20 Correct 22 ms 47320 KB Output is correct
21 Correct 23 ms 47260 KB Output is correct
22 Correct 22 ms 47256 KB Output is correct
23 Correct 22 ms 47316 KB Output is correct
24 Correct 22 ms 47280 KB Output is correct
25 Correct 24 ms 47328 KB Output is correct
26 Correct 23 ms 47316 KB Output is correct
27 Correct 25 ms 47316 KB Output is correct
28 Correct 24 ms 47300 KB Output is correct
29 Correct 23 ms 47592 KB Output is correct
30 Correct 22 ms 47444 KB Output is correct
31 Correct 22 ms 47368 KB Output is correct
32 Correct 23 ms 47336 KB Output is correct
33 Correct 22 ms 47332 KB Output is correct
34 Correct 24 ms 47412 KB Output is correct
35 Correct 23 ms 47424 KB Output is correct
36 Correct 23 ms 47316 KB Output is correct
37 Correct 23 ms 47392 KB Output is correct
38 Correct 24 ms 47368 KB Output is correct
39 Correct 22 ms 47316 KB Output is correct
40 Correct 23 ms 47316 KB Output is correct
41 Correct 22 ms 47252 KB Output is correct
42 Correct 23 ms 47352 KB Output is correct
43 Correct 22 ms 47300 KB Output is correct
44 Correct 22 ms 47316 KB Output is correct
45 Correct 22 ms 47316 KB Output is correct
46 Correct 22 ms 47348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 47300 KB Output is correct
2 Correct 22 ms 47268 KB Output is correct
3 Correct 25 ms 47316 KB Output is correct
4 Correct 23 ms 47340 KB Output is correct
5 Correct 23 ms 47296 KB Output is correct
6 Correct 23 ms 47312 KB Output is correct
7 Correct 23 ms 47316 KB Output is correct
8 Correct 22 ms 47316 KB Output is correct
9 Correct 22 ms 47288 KB Output is correct
10 Correct 22 ms 47368 KB Output is correct
11 Correct 22 ms 47284 KB Output is correct
12 Correct 22 ms 47316 KB Output is correct
13 Correct 22 ms 47248 KB Output is correct
14 Correct 22 ms 47304 KB Output is correct
15 Correct 28 ms 47264 KB Output is correct
16 Correct 27 ms 47356 KB Output is correct
17 Correct 24 ms 47368 KB Output is correct
18 Correct 26 ms 47308 KB Output is correct
19 Correct 28 ms 47288 KB Output is correct
20 Correct 22 ms 47320 KB Output is correct
21 Correct 23 ms 47260 KB Output is correct
22 Correct 22 ms 47256 KB Output is correct
23 Correct 22 ms 47316 KB Output is correct
24 Correct 22 ms 47280 KB Output is correct
25 Correct 24 ms 47328 KB Output is correct
26 Correct 23 ms 47316 KB Output is correct
27 Correct 25 ms 47316 KB Output is correct
28 Correct 24 ms 47300 KB Output is correct
29 Correct 23 ms 47592 KB Output is correct
30 Correct 22 ms 47444 KB Output is correct
31 Correct 22 ms 47368 KB Output is correct
32 Correct 23 ms 47336 KB Output is correct
33 Correct 22 ms 47332 KB Output is correct
34 Correct 24 ms 47412 KB Output is correct
35 Correct 23 ms 47424 KB Output is correct
36 Correct 23 ms 47316 KB Output is correct
37 Correct 23 ms 47392 KB Output is correct
38 Correct 24 ms 47368 KB Output is correct
39 Correct 22 ms 47316 KB Output is correct
40 Correct 23 ms 47316 KB Output is correct
41 Correct 22 ms 47252 KB Output is correct
42 Correct 23 ms 47352 KB Output is correct
43 Correct 22 ms 47300 KB Output is correct
44 Correct 22 ms 47316 KB Output is correct
45 Correct 22 ms 47316 KB Output is correct
46 Correct 22 ms 47348 KB Output is correct
47 Correct 147 ms 64596 KB Output is correct
48 Correct 143 ms 65144 KB Output is correct
49 Correct 173 ms 70760 KB Output is correct
50 Incorrect 511 ms 138576 KB Integer parameter [name=number of subsequences] equals to 0, violates the range [1, 967248]
51 Halted 0 ms 0 KB -