제출 #1305668

#제출 시각아이디문제언어결과실행 시간메모리
1305668ayazArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define isz(x) (int)x.size()
#define int long long
long long count_swaps(std::vector<int> s) {
  vector<int> a = s;
  int n = isz(a);
  return (n / 2) * (n / 2 - 1) / 2;
  if (n == 2) {
    return (a[0] > 0);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] > 0) {
      int d = 1e9;
      for (int j = i + 1; j < n; j++) {
        if (a[j] + a[i] == 0) {
          d = j;
          break;
        }
      }
      ans += (d - i);
      for (int j = d; j > i; j--) swap(a[j], a[j - 1]);
      continue;
    }
    if (i % 2 == 1 && (a[i] < 0 || (a[i - 1] + a[i]) != 0)) {
      int d = 1e9;
      for (int j = i + 1; j < n; j++) {
        if (a[j] + a[i - 1] == 0) {
          d = j;
          break;
        }
      }
      ans += (d - i);
      for (int j = d; j > i; j--) swap(a[j], a[j - 1]);
    }
  }
  for (int i = 0; i < n; i += 2) {
    ans += (a[i] > 0);
  }
  if (ans != (n / 2) * (n / 2 - 1) / 2) {
    for (int i = 0; i < n; i++){
      cout << a[i] << ' ';
    }
    cout << '\n';
    exit(0);
  }
  return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccvtGfSq.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status