CSES - Datatähti 2017 alku - Results
Submission details
Task:Järjestys
Sender:Senpai
Submission time:2016-10-12 21:41:29 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:52:1: error: expected '}' at end of input
 }
 ^

Code

#include <bits/stdc++.h>
using namespace std;

long long a,b,n,x,y;
vector<long long>s;
 vector<long long> v;

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
    cin >> n;
    vector <long long> t(100002);
  for(int i=0; i<n;i++){
      cin>>b;
      v.push_back(b);
      t[b-1]=i;
      
  }

    
 
    
    
     for(int i=n; i>0;i--){
         if(v[i-1]!=i){
          int m= t[i-1];
             if(v[0]!=i){y++; 
                         s.push_back(m+1);
                         reverse(v.begin(),v.begin()+(m+1));
                        reverse(t.begin(),t.begin()+(m+1));
                        
                         
             reverse(v.begin(),v.end()-x);
             
               
              y++;          
             
            s.push_back(n-x);
             
    }
          x++;
     }
    
   cout<<y<<"\n";
    for(int i=0; i<y;i++){
        cout<<s[i]<<" ";
    }
     
   
    
   
}