제출 #303826

#제출 시각아이디문제언어결과실행 시간메모리
303826noob_c0deArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define int long long
const int mxn=2e5+3;
int n;
vector<int> pos[mxn],neg[mxn];
int ft[2*mxn];
int vis[mxn];
void upd(int u,int d)
{
    while(u<=n)
    {
        ft[u]+=d;
        u+=u&-u;
    }
}
int get(int u)
{
    int res=0;
    while(u)
    {
        res+=ft[u];
        u-=u&-u;
    }
    return res;
}
int count_swaps(vector<int> a)
{
    n=a.size();
    for (int i=n;i>=1;i--)
    {
        if (a[i-1]>0) pos[a[i-1]].push_back(i);
        else neg[-a[i-1]].push_back(i);
    }
    long long ans=0;
    for (int i=1;i<=n;i++)
    if (!vis[i])
    {
        int vt;
        if (a[i-1]>0) vt=neg[a[i-1]].back();
        else vt=pos[-a[i-1]].back();
        pos[abs(a[i-1])].pop_back();
        neg[abs(a[i-1])].pop_back();
        ans+=(vt+get(vt))-(i+get(i))-1;
        if (a[i-1]>0) ans++;
        upd(1,1);
        if (vt+1<=n) upd(vt+1,-1);
        vis[vt]=1;
    }
    return(ans);
}

컴파일 시 표준 에러 (stderr) 메시지

/tmp/cchDJt9L.o: In function `main':
grader.cpp:(.text.startup+0x27a): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status