Submission #670605

#TimeUsernameProblemLanguageResultExecution timeMemory
670605birthdaycakeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "shoes.h"
using namespace std;

long long count_swaps(vector<int>s) {
    long long n = s.size(); long long ans = 0;
    for(long long i = 0; i < n; i++){
        long long f = 0;
        for(long long j = 0; j < i; j++){
            if(!vs[j] && s[i] == -s[j]){
                f = j + 1;
                break;
            }
        }
        if(f){
            f--;
            long long j = i;
            vs[f] = vs[f + 1] = 1;
            while(j != f + 1){
                swap(s[j], s[j - 1]);
                j--;
                ans++;
            }
            if(s[f] > 0) {
                swap(s[f], s[f + 1]);
                ans++;
            }
        }
        
    }
    
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:17: error: 'vs' was not declared in this scope; did you mean 's'?
   10 |             if(!vs[j] && s[i] == -s[j]){
      |                 ^~
      |                 s
shoes.cpp:18:13: error: 'vs' was not declared in this scope; did you mean 's'?
   18 |             vs[f] = vs[f + 1] = 1;
      |             ^~
      |             s