Submission #206885

#TimeUsernameProblemLanguageResultExecution timeMemory
206885Sho10Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
/*
ID: Sho10
LANG: C++
*/
#include "shoes.h"
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<int>v;
vector<int>l;
vector<int>r;
ll count_swaps(std::vector<int> S){
    v=S;
    ll ans=0;
 for(ll i=0;i<n;i++)
 {
     if(v[i]%2==0){
        if(v[i]>0){
            for(ll j=i+1;j<n;j++)
            if(v[j]<0){
                for(ll c=j;c>i;c--){
                    swap(v[c],v[c-1]);
                    ans++;
                }
                    break;
            }
        }else {
        for(ll j=i+1;j<n;j++)
        if(-v[j]==v[j-1]){
            for(ll c=j;c>i;c--){
                swap(v[c],v[c-1]);
                ans++;
            break;
        }
     }
 }
}
 }
 return ans;
}


Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:31:15: error: 'n' was not declared in this scope
  for(ll i=0;i<n;i++)
               ^