제출 #1306446

#제출 시각아이디문제언어결과실행 시간메모리
1306446baodatArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, l, r) for(int i = l; i <= r; i++) #define FORD(i, l, r) for(int i = l; i >= r; i--) #define all(x) (x).begin(), (x).end() struct BIT{ int n; vector<int> bit; BIT(int __n = 0){ init(__n); } void init(int __n = 0){ n = __n; bit.assign(n + 5, 0); } void update(int i, int v){ ++i; while(i <= n){ bit[i] += v; i += i &-i; } } int query(int i){ ++i; int ans = 0; while(i > 0){ ans += bit[i]; i -= i &-i; } return ans; } int query(int l, int r){ return query(r) - query(l - 1); } }; ll count_swaps(vector<int> a){ int n = a.size(); int maxi = *max_element(all(a)); BIT bit(n + 1); vector<int> pos(n + 1, 0), match(n + 1, -1), last(maxi + 1, -1); FOR(i, 0, n - 1){ int x = abs(a[i]); if(last[x] == -1) last[x] = i; else{ match[i] = last[x]; match[last[x]] = i; } } //FOR(i, 0, n - 1) cout << i << ": " << match[i] << " "; ll ans = 0; FOR(i, 0, n - 1) bit.update(i, 1); vector<bool> used(n, false); FOR(i, 0, n - 1){ if(used[i]) continue; int j = match[i]; if(i > j) continue; ans += bit.query(i + 1, j - 1); bit.update(i, -1); bit.update(j, -1); if(a[i] > 0) ++ans; used[i] = used[j] = true; } return ans; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int>a(2 * n); FOR(i, 0, 2 * n - 1) cin >> a[i]; cout << count_swaps(a) << "\n"; return 0; }

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

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