Submission #474108

#TimeUsernameProblemLanguageResultExecution timeMemory
474108ValiAntonieArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(vector<int> v){ int indice = -1; int v[100001]; int i = 0, nr = 0, numar = 0, j = 0, j2 = 0, nr2; int n = v.size(); for(i=0;i<n;i++) v2[i] = v[i]; for(i=0;i<n;i++){ if(v2[i] > 0 && v2[i+1] < 0){ swap(v2[i],v2[i+1]); nr2++; } } for(i=0;i<n;i++){ if(v2[i] != -v2[i+1] && v2[i+1] != -v2[i+2] && v2[i] > 0){ swap(v2[i],v2[i+1]); nr2++; } } for(i=indice;i<n;i++){ if(v[i] < 0){ indice++; numar = -v[i]; for(j=i;j>indice;j--){ swap(v[j],v[j-1]); nr++; } indice++; for(j2=1;j2<n;j2++){ if(v[j2] == numar){ for(j=i;j>indice;j--){ swap(v[j],v[j-1]); nr++; } } } i = indice; } } return min(nr,nr2); }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:5: error: declaration of 'int v [100001]' shadows a parameter
    6 | int v[100001];
      |     ^
shoes.cpp:4:35: note: 'std::vector<int> v' previously declared here
    4 | long long count_swaps(vector<int> v){
      |                       ~~~~~~~~~~~~^
shoes.cpp:8:11: error: request for member 'size' in 'v', which is of non-class type 'int [100001]'
    8 | int n = v.size();
      |           ^~~~
shoes.cpp:10:3: error: 'v2' was not declared in this scope; did you mean 'j2'?
   10 |   v2[i] = v[i];
      |   ^~
      |   j2
shoes.cpp:12:8: error: 'v2' was not declared in this scope; did you mean 'j2'?
   12 |     if(v2[i] > 0 && v2[i+1] < 0){
      |        ^~
      |        j2
shoes.cpp:18:8: error: 'v2' was not declared in this scope; did you mean 'j2'?
   18 |     if(v2[i] != -v2[i+1] && v2[i+1] != -v2[i+2] && v2[i] > 0){
      |        ^~
      |        j2