Submission #474099

# Submission time Handle Problem Language Result Execution time Memory
474099 2021-09-16T22:09:34 Z ValiAntonie Arranging Shoes (IOI19_shoes) C++14
Compilation error
0 ms 0 KB
#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> v){
indice = -1;
int i = 0, nr = 0, numar = 0;
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 nr;
}

Compilation message

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:5:1: error: 'indice' was not declared in this scope
    5 | indice = -1;
      | ^~~~~~
shoes.cpp:7:17: error: 'n' was not declared in this scope; did you mean 'nr'?
    7 | for(i=indice;i<=n;i++){
      |                 ^
      |                 nr
shoes.cpp:11:13: error: 'j' was not declared in this scope
   11 |         for(j=i;j>indice;j--){
      |             ^
shoes.cpp:16:13: error: 'j2' was not declared in this scope; did you mean 'jn'?
   16 |         for(j2=1;j2<=n;j2++){
      |             ^~
      |             jn
shoes.cpp:18:16: error: 'j' was not declared in this scope
   18 |            for(j=i;j>indice;j--){
      |                ^