Submission #532876

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

int64 count_swaps(int[] s){
  int n = s.size(), ans = 0;
  for(int i=0;i<2*n;i+=2)
  {
    for(int j=i+1;j<2*n;j++)
    {
      if(abs(s[j]) == abs(s[i]))
      {
        ans += j - i - 1;
        for(int k=j-1;k>=i+1;k--) swap(s[k], s[k+1]);
        break;
      }
    }
    if(s[i] > s[i + 1])
    {
      ans += 1;
      swap(s[i], s[i + 1]);
    }
  }
  return ans;
}

// int main(){
//   int t1[] = {2, 1, -1, -2};
//   int t2[] = {-2, 2, 2, -2, -2, 2};
//   cout << count_swaps(t2) << '\n';
// }

Compilation message (stderr)

shoes.cpp:4:1: error: 'int64' does not name a type; did you mean 'int64_t'?
    4 | int64 count_swaps(int[] s){
      | ^~~~~
      | int64_t