Submission #1145662

#TimeUsernameProblemLanguageResultExecution timeMemory
1145662MunkhturErdenebatArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(vector<int> s) {
    int a = s.size();
    vector<int> maa(a, 0);
    long long h = 0;
    
    for(int i = 0; i < a; i++) {
        if(maa[i] == 1) continue;
        
        for(int j = i + 1; j < a; j++) {
            if(s[j] + s[i] == 0 && maa[j] == 0) {
                g = j;
                break;
            }
        }
        

        for(int j = g - 1; j > i; j--) {
            if(maa[j] == 0) h++;
        }
        if(s[i]>0){
            h++;
        }
        maa[g] = 1;
    }
    return h;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:14:17: error: 'g' was not declared in this scope
   14 |                 g = j;
      |                 ^
shoes.cpp:20:21: error: 'g' was not declared in this scope
   20 |         for(int j = g - 1; j > i; j--) {
      |                     ^
shoes.cpp:26:13: error: 'g' was not declared in this scope
   26 |         maa[g] = 1;
      |             ^