Submission #294915

#TimeUsernameProblemLanguageResultExecution timeMemory
294915ASDF123Arranging Shoes (IOI19_shoes)C++17
50 / 100
1089 ms2680 KiB

#include "shoes.h"
#include <bits/stdc++.h>
#define ll long long
#define szof(s) (int)s.size()

using namespace std;

const int N = (int)2e5 + 5;

ll count_swaps(vector<int> s) {
  ll ans = 0;
  int n = szof(s) / 2;
  for (int i = 0; i < n * 2; i += 2) {
    int pos = -1;
    for (int j = i + 1; j < n * 2; j++) {
      if (s[j] == -s[i]) {
        pos = j;
        break;
      }
    }
    while (pos > i + 1) {
      swap(s[pos], s[pos - 1]);
      pos--;
      ans++;
    }
    if (s[pos] < 0) {
      swap(s[pos], s[pos - 1]);
      ans++;
    }
  }
  return ans;
}

//signed main() {
  
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...