Submission #155328

#TimeUsernameProblemLanguageResultExecution timeMemory
155328Sasuke0004Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pb push_back
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define tree int h,int l,int r,int L,int R
using namespace std;
ll sg[2000006],fx[2000006],n,ans;
vector<int>v[100006];
void upd(tree)
{
    if(l>r)return;
    if(l>R)return;
    if(L>r)return;
    if(l==r)
    {
        sg[h]=sg[h]^(1);
        return;
    }
    sg[h]=sg[2*h]+sg[2*h+1];
}
ll get(tree)
{
    if(l>r)return 0;
    if(l>R)return 0;
    if(L>r)return 0;
    if(l>=L && r<=R)return sg[h];
    else return get(left)+get(right);
}
int64_t count_swaps(int x[])
{
    n=(sizeof(x)/sizeof(x[0]));
    for(int i=0;i<n;i++)
    {
        v[n+x[i]].pb(i);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<int(v[i].size());j++)
        {
            if(v[i][j]>v[i+n][j]){ans++;swap(v[i][j],v[i+n][j]);}
            fx[v[i][j]]=v[i+n][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        upd(1,0,n-1,i,i);
    }
    for(int i=0;i<n;i++)
    {
        ans+=get(1,0,n-1,i,fx[i]);
        upd(1,0,n-1,fx[i],fx[i]);
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'int64_t count_swaps(int*)':
shoes.cpp:35:16: warning: 'sizeof' on array function parameter 'x' will return size of 'int*' [-Wsizeof-array-argument]
     n=(sizeof(x)/sizeof(x[0]));
                ^
shoes.cpp:33:27: note: declared here
 int64_t count_swaps(int x[])
                           ^
/tmp/ccWxWa4P.o: In function `main':
grader.cpp:(.text.startup+0x282): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status