제출 #1026383

#제출 시각아이디문제언어결과실행 시간메모리
1026383ezzzayArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int bit[N];
int a[N];
vector<int>v[N];
vector<int>ans;
int n;
int find(int idx){
    int s=0;
    while(idx>0){
        s+=bit[idx];
        idx-= idx & -idx;
    }
    return s;
}
void update(int idx, int val){
    while(idx<N){
        bit[idx]+=val;
        idx+= idx & -idx;
    }
}
int fun(){
    map<int,int>mp;
    for(int i=0;i<N;i++)bit[i]=0;
    for(int i=1;i<=n;i++){
        mp[a[i]];
    }
    int idx=1;
    for(auto it=mp.begin();it!=mp.end();it++){
        it->ss = idx++;
    }
    for(int i=1;i<=n;i++){
        a[i]=mp[a[i]];
    }
    int s=0;
    
    for(int i=1;i<=n;i++){
        update(a[i],1);
        s+=i-find(a[i]);
    }
    return s;
}
long long count_swaps(vector<int> s) {
    n=s.size();
   vector<pair<int,int>>vc;
    for(int i=0;i<n;i++){
        if(s[i]<0){
            vc.pb({i,s[i]});
        }
        else{
            v[s[i]].pb(i);
        }
    }
    for(int i=0;i<3e5;i++){
        reverse(v[i].begin(),v[i].end());
    }
    sort(vc.begin(),vc.end());
    for(int i=0;i<n/2;i++){
        int h=vc[i].ss*-1;
        a[vc[i].ff+1]=i*2+1;
       // a[i*2+1]=vc[i].ff+1;
        a[v[h].back()+1]=i*2+2;
        //a[i*2+2]=v[h].back()+1;
        v[h].pop_back();
    }
    return fun();
    
}

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

/usr/bin/ld: /tmp/cckcVt3K.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