Submission #721358

#TimeUsernameProblemLanguageResultExecution timeMemory
721358sofija6Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
struct bit
{
    vector<ll> v;
    void Init()
    {
        v.resize(n+5);
    }
    void Add(ll pos,ll val)
    {
        for (ll i=pos;i<=n;i+=i&(-i))
            v[i]+=val;
    }
    ll Sum(ll pos)
    {
        ll ans=0;
        for (ll i=pos;i>0;i-=i&(-i))
            ans+=v[i];
        return ans;
    }
    ll Calc(ll l,ll r)
    {
        return Sum(r)-Sum(l-1);
    }
};
ll count_swaps(ll S[])
{
    n=sizeof(S);
    bit B;
    B.Init();
    map<ll,priority_queue<ll> > posl,posr;
    ll ans=0;
    for (ll i=0;i<n;i++)
    {
        if (S[i]>0)
        {
            if (posl[S[i]].empty())
            {
                B.Add(i+1,1);
                posr[S[i]].push(i+1);
                continue;
            }
            ll t=posl[S[i]].top();
            posl[S[i]].pop();
            ans+=B.Calc(t+1,i+1);
            B.Add(t,-1);
            B.Add(i+1,2);
            continue;
        }
        if (posr[-S[i]].empty())
        {
            B.Add(i+1,1);
            posl[-S[i]].push(i+1);
            continue;
        }
        ll t=posr[-S[i]].top();
        posr[-S[i]].pop();
        ans+=B.Calc(t,i+1);
        B.Add(t,-1);
        B.Add(i+1,2);
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(long long int*)':
shoes.cpp:31:14: warning: 'sizeof' on array function parameter 'S' will return size of 'long long int*' [-Wsizeof-array-argument]
   31 |     n=sizeof(S);
      |             ~^~
shoes.cpp:29:19: note: declared here
   29 | ll count_swaps(ll S[])
      |                   ^
/usr/bin/ld: /tmp/ccPlKy4U.o: in function `main':
grader.cpp:(.text.startup+0x29d): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status