제출 #954831

#제출 시각아이디문제언어결과실행 시간메모리
954831AcanikolicArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; const int N = 1e5 + 10; const int mod = 1e9 + 7; const int inf = 1e9; int fenw[N]; void add(int index,int n,int val) { while(index <= n) { fenw[index] += val; index += index & -index; } } int get(int index) { int ret = 0; while(index >= 1) { ret += fenw[index]; index -= index & -index; } return ret; } long long count_swaps(vector<int>a) { int n = a.size(); vector<int>p(n + 1); vector<int>g[n + 1][2];//0 neg 1 pos for(int i = 0; i < n; i++) { if(a[i] < 0) g[-a[i]][0].pb(i + 1); else g[a[i]][1].pb(i + 1); } int index = 1; for(int i = 1; i <= n; i++) { for(int j = 0; j < (int)g[i][0].size(); j++) { p[g[i][0][j]] = index++; p[g[i][1][j]] = index++; } } long long res = 0; for(int i = 1; i <= n; i++) { res += get(n) - get(p[i]); add(p[i],n,1); } return res; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int>a(n); for(int i = 0; i < n; i++) cin >> a[i]; cout << count_swaps(a); return 0; }

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

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