CSES - Datatähti 2017 alku - Results
Submission details
Task:Pakkaus
Sender:Senpai
Submission time:2016-10-16 22:33:45 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:8:11: error: redefinition of 'long long int a'
 long long a,b,n,x,y;
           ^
input/code.cpp:4:11: error: 'long long int a' previously declared here
 long long a,b,n,x,y;
           ^
input/code.cpp:8:13: error: redefinition of 'long long int b'
 long long a,b,n,x,y;
             ^
input/code.cpp:4:13: error: 'long long int b' previously declared here
 long long a,b,n,x,y;
             ^
input/code.cpp:8:15: error: redefinition of 'long long int n'
 long long a,b,n,x,y;
               ^
input/code.cpp:4:15: error: 'long long int n' previously declared here
 long long a,b,n,x,y;
               ^
input/code.cpp:8:17: error: redefinition of 'long long int x'
 long long a,b,n,x,y;
                 ^
input/code.cpp:4:17: error: 'long long int x' previously declared here
 long long a,b,n,x,y;
                 ^
input/code.cpp:8:19: error: redefinition of 'long long int y'
 long long a,b,n,x,y;
                   ^
input/code.cpp:4:19: error: 'long long int y' prev...

Code

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

long long a,b,n,x,y;
#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;
  for(int i=0; i<n;i++){
      cin>>b;
      v.push_back(b);   
  }
     while(n!=0){
         if(v[0]==1){
             if(is_sorted(v.begin(),v.end()))
                break;
         }
         int k=0;
    if (v[0]==n){
        for(int i=n-1; i>=0; i--){
            x=i;
            if(abs(v[i]-v[i-1])!=1 && i!=0) {
               
                s.push_back(i);
                reverse(v.begin(),v.begin()+i);
                break;
 
         }
           else{
           s.push_back(n);
               reverse(v.begin(),v.begin()+i);
               a++;
                break;
               
           }  
             
         
            }
           
        
      if(a==1){
          break;
      }
    }
else if(v[1]==v[0]+1){
             while(v[k+2]!=v[0]-1 && k!=n-1){k++;}
             s.push_back(k+2);
             reverse(v.begin(),v.begin()+(k+2));

         }
          else if(v[1]!=v[0]+1){
                 while(v[k+1]!=v[0]+1 && k!=n-1){k++;}
                 s.push_back(k+1);
                 reverse(v.begin(),v.begin()+(k+1));
 
         }
            
            
         else {a=a;

         }
         
     }
      y=s.size();
cout<<y<<"\n";
for(int i=0; i<y;i++){
    cout<<s[i]<<" ";
     }
}