Submission #891583

#TimeUsernameProblemLanguageResultExecution timeMemory
891583ArpArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

using i64 = long long;

i64 count_swaps(vector<int> arr){
  int n = arr.size();
  map<int,int> mp;
  vector<int> bit(n + 1);
  i64 ans = 0;
  for(int i = 0;i<n;i++){
    int e = arr[i];
    int ind;
    if(mp.find(-e) == mp.end()){
      ind = i + 1;
      mp[e] = ind;
    }else{
      ind = mp[-e];
      mp.erase(-e);
      ans += i; // implementation skills
      for(int j = ind;j > 0;j -= (j & -j)){
        ans -= bit[j];
      } 
      if(e < 0) ans ++;
    }
    // adding twice if found both the pair
    for(;ind <= n;ind += (ind & -ind)){
      bit[ind] ++;
    }
  }
  return ans;
}

int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccATjozY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccXMrV11.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status