Submission #146774

#TimeUsernameProblemLanguageResultExecution timeMemory
146774youssan_williamArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
typedef long long ll;
bool v[100005];
ll count_swaps( vector<ll>s )
{
    ll n = s.size();
    ll tmp;
    ll ans=0;
    for(int i = 1 ; i <=2*n ; i++)
    {
        if(!v[abs(s[i])])
        {
            v[abs(s[i])]=1;
            for(int j =i+1 ; j <= 2 * n ;j++)
            {
                if(abs(s[i])==abs(s[j]))
                {
                    for(int k=j-1 ; k>i ;k--)
                    {
                        swap(arr[k],arr[k+1]);
                        ans++;
                    }
                    break;
                }
            }
        }
    }
    for(int i = 1 ;  i <=2*n ;i++ )
    {
        if(i%2==1&&s[i]>s[i+1])
            ans++;
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<long long int>)':
shoes.cpp:22:30: error: 'arr' was not declared in this scope
                         swap(arr[k],arr[k+1]);
                              ^~~
shoes.cpp:9:8: warning: unused variable 'tmp' [-Wunused-variable]
     ll tmp;
        ^~~