Language: C++


int gunc(int i){
  int ans=1;
  for(int j=i;j>0;j--){
    ans *= j;
  }
  return ans;
}

int func(vector<int> vec,int n){
  int k=1;
  int m=n;
  for(int i=0;i<n-1;i++){
    k += (vec.at(i)-1)*gunc(m-1);
    m--;
  }
  return k;
}

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> q.at(i);
  }
  
  cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
  cout << func(p,n) << endl;
  
  return 0;
}

Compiler output:
a.cc:10:10: error: 'vector' was not declared in this scope
   10 | int func(vector<int> vec,int n){
      |          ^~~~~~
a.cc:10:17: error: expected primary-expression before 'int'
   10 | int func(vector<int> vec,int n){
      |                 ^~~
a.cc:10:26: error: expected primary-expression before 'int'
   10 | int func(vector<int> vec,int n){
      |                          ^~~
a.cc:10:31: error: expression list treated as compound expression in initializer [-fpermissive]
   10 | int func(vector<int> vec,int n){
      |                               ^
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope
   22 |   cin >> n;
      |   ^~~
a.cc:23:3: error: 'vector' was not declared in this scope
   23 |   vector<int> p(n),q(n);
      |   ^~~~~~
a.cc:23:10: error: expected primary-expression before 'int'
   23 |   vector<int> p(n),q(n);
      |          ^~~
a.cc:25:12: error: 'p' was not declared in this scope
   25 |     cin >> p.at(i);
      |            ^
a.cc:28:12: error: 'q' was not declared in this scope
   28 |     cin >> q.at(i);
      |            ^
a.cc:31:3: error: 'cout' was not declared in this scope
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |   ^~~~
a.cc:31:20: error: 'p' was not declared in this scope
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                    ^
a.cc:31:19: error: 'func' cannot be used as a function
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |               ~~~~^~~~~
a.cc:31:30: error: 'q' was not declared in this scope
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                              ^
a.cc:31:29: error: 'func' cannot be used as a function
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                         ~~~~^~~~~
a.cc:31:39: error: 'func' cannot be used as a function
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                                   ~~~~^~~~~
a.cc:31:50: error: 'func' cannot be used as a function
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                                              ~~~~^~~~~
a.cc:31:11: error: 'max' was not declared in this scope
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |           ^~~
a.cc:31:60: error: 'endl' was not declared in this scope
   31 |   cout << max(func(p,n)-func(q,n),func(q,n) -func(p,n)) << endl;
      |                                                            ^~~~
a.cc:32:15: error: 'func' cannot be used as a function
   32 |   cout << func(p,n) << endl;
      |           ~~~~^~~~~