제출 #520887

#제출 시각아이디문제언어결과실행 시간메모리
520887joshjmsArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define sp " " #define debug(x) cout << #x << " => " << x << "\n" const int mod = 1e9 + 7; const ld err = 1e-6; int n, arr[200005]; vector <int> pos[200005]; bool vis[200005]; ll ans; struct fenwick_tree{ int bit[200005]; void upd(int idx, int val){ for(; idx <= 2 * n; idx += (idx & -idx)){ bit[idx] += val; } } int query(int idx){ int res = 0; for(; idx >= 1; idx -= (idx & -idx)){ res += bit[idx]; } return res; } int query(int l, int r){ return query(r) - query(l - 1); } } fwt; long long count_swaps(vector<int> s) { n = s.size() / 2; for(int i = 1; i <= 2 * n; i++) arr[i] = s[i - 1]; for(int i = 2 * n; i >= 1; i--){ pos[arr[i] + n].pb(i); } for(int i = 1, u, v; i <= 2 * n; i++){ if(vis[i]) continue; u = i; v = pos[arr[i] * (-1) + n].back(); vis[u] = vis[v] = 1; pos[arr[i] + n].pop_back(); pos[arr[i] * (-1) + n].pop_back(); if(arr[i] < 0) ans += (v - u - 1) - fwt.query(u, n) + fwt.query(v, n); else ans += (v - u) - fwt.query(u, n) + fwt.query(v, n); fwt.upd(v, 1); } return ans; } int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; }

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

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