제출 #1332281

#제출 시각아이디문제언어결과실행 시간메모리
1332281riafhasan2010Arranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll count_swaps(vector<int> s) {
  int n = s.size(); 
  vector<queue<int>> l(n + 1), r(n + 1);
  for (int i = 0; i < n; i++) {
    (s[i] < 0 ? l : r)[abs(s[i])].push(i);
    s[i] = abs(s[i]);
  }
  vector<bool> vis(n + 1, 0);
  vector<int> v;
  ll ans = 0;
  for (int i = 0, cur = 0; i < n; i++) {
    if (vis[i]) continue;
    int left = l[s[i]].front(); l[s[i]].pop();
    int right = r[s[i]].front(); r[s[i]].pop();
    vis[left] = vis[right] = true;
    int leftind = upper_bound(v.begin(), v.end(), left) - v.begin();
    leftind = left + v.size() - leftind;
    ans += abs(leftind - cur * 2);
    v.insert(upper_bound(v.begin(), v.end(), left), left);
    int rightind = upper_bound(v.begin(), v.end(), right) - v.begin();
    rightind = right + v.size() - rightind;
    ans += abs(rightind - (cur * 2 + 1));
    v.insert(upper_bound(v.begin(), v.end(), right), right);
    cur++;
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n; cin >> n; n *= 2;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cout << count_swaps(s) << '\n';
}

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

/usr/bin/ld: /tmp/cc7JvuY7.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLfXY2l.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status