Submission #1026382

#TimeUsernameProblemLanguageResultExecution timeMemory
1026382ezzzayArranging Shoes (IOI19_shoes)C++14
Compilation error
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;
    }
}
void 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();
    
}

Compilation message (stderr)

shoes.cpp: In function 'void fun()':
shoes.cpp:47:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   47 |     return s;
      |            ^
shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:72:15: error: void value not ignored as it ought to be
   72 |     return fun();
      |            ~~~^~