Submission #212641

#TimeUsernameProblemLanguageResultExecution timeMemory
212641Aydarov03Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
/*
  no pain, no gain
*/

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define pii pair<int, int>
#define all(s) s.begin(), s.end()
#define prev myrza4321
#define y1 myrza1234
#define OK puts("OK")
using namespace std;

const int N = (int)1e5 + 5;
const int INF = 0x3f3f3f3f;

int a[N];

/*
4
2 1 -1 -2
*/

main() {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  int ans = 0;
  for (int l = 0; l < n; l += 2) {
    int lst = -1;
    if (a[l] < 0) {
      lst = l + 1;
    } else {
      lst = l;
    }

    for (int r = l + 1; r < n; r++) {
      if (a[r] == -a[l]) {
        int pos = r;
        while (pos > lst) {
          swap(a[pos], a[pos - 1]);
          pos--, ans++;
        }
        break;
      }
    }
  }
  cout << ans;
}

Compilation message (stderr)

shoes.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
shoes.cpp: In function 'int main()':
shoes.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
     ~~~~~^~~~~~~~~~~~~
/tmp/ccnsb9Eq.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccE0iOVS.o:shoes.cpp:(.text.startup+0x0): first defined here
/tmp/ccnsb9Eq.o: In function `main':
grader.cpp:(.text.startup+0x282): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status