제출 #726962

#제출 시각아이디문제언어결과실행 시간메모리
726962viwlesxqArt Exhibition (JOI18_art)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int64_t ll;
typedef string str;

#define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

ll count_swaps(int S[]) {
  int n = (int)sizeof(S) >> 2;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    S[i] += n;
  }
  vector <deque <int>> pos(2 * n + 1);
  vector <bool> used(n, false);
  ordered_set st;
  for (int i = 0; i < n; ++i) {
    pos[S[i]].push_back(i);
  }
  for (int i = 0; i + 1 < n; ++i) {
    if (used[S[i]]) {
      continue;
    }
    if (S[i] > n) {
      int left = S[i] - n, right = S[i];
      int from = pos[left].front();
      ans += from - i;
      ans -= (int)st.order_of_key(from + 1) - (int)st.order_of_key(i);
      st.insert(i), st.insert(from);
      used[i] = true, used[from] = true;
      pos[left].pop_front(), pos[right].pop_front();
    } else {
      int left = S[i], right = S[i] + n;
      int from = pos[right].front();
      ans += from - i - 1;
      ans -= (int)st.order_of_key(from + 1) - (int)st.order_of_key(i);
      st.insert(i), st.insert(from);
      used[i] = true, used[from] = true;
      pos[left].pop_front(), pos[right].pop_front();
    }
  }
  return ans;
}

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

art.cpp: In function 'll count_swaps(int*)':
art.cpp:14:23: warning: 'sizeof' on array function parameter 'S' will return size of 'int*' [-Wsizeof-array-argument]
   14 |   int n = (int)sizeof(S) >> 2;
      |                      ~^~
art.cpp:13:20: note: declared here
   13 | ll count_swaps(int S[]) {
      |                ~~~~^~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status