Submission #723978

#TimeUsernameProblemLanguageResultExecution timeMemory
723978sandry24Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define pb push_back #define mp make_pair #define f first #define s second const int sz = 100005; vector<int> BIT(sz); void add(int x, int delta){ for(; x <= sz; x += x & -x) BIT[x] += delta; } ll sum(int x){ ll res = 0; for(; x > 0; x -= x & -x) res += BIT[x]; return res; } int count_swaps(vi s){ map<int, vi> m; int n = s.size(); vector<bool> marked(n); for(int i = 0; i < n; i++) m[s[i]].pb(i); for(auto i : m) reverse(i.s.begin(), i.s.end()); ll ans = 0; for(int i = 0; i < n; i++){ if(marked[i]) continue; int need = -s[i]; int ind = m[need].back(); m[ind].pop_back(); m[s[i]].pop_back(); marked[i] = marked[ind] = 1; //cout << s[i] << ' ' << i << ' ' << ind << ' ' << sum(ind) << '\n'; ans += (ind - i - 1) - (sum(ind+1) - sum(i+1)); if(s[i] > 0) ans++; add(ind+1, 1); //cout << ans << '\n'; } return ans; } void solve(){ int n; cin >> n; vi a(n); for(int i = 0; i < n; i++) cin >> a[i]; cout << count_swaps(a) << '\n'; } int main(){ //freopen("input.txt", "r", stdin); //freopen("test.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

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