Submission #388603

#TimeUsernameProblemLanguageResultExecution timeMemory
388603cpp219Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#pragma GCC optimization "Ofast" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 2e5 + 6; const ll lim = 3e5 + 6; const ll inf = 1e9 + 7; typedef pair<ll,ll> LL; vector<ll> pos[N],neg[N]; ll bit[N]; bool was[N]; void upd(ll p,ll val){ for (ll i = p;i < N;i += i & -i) bit[i] += val; } ll Get(ll p){ ll res = 0; for (ll i = p;i > 0;i -= i & -i) res += bit[i]; return res; } ll Query(ll L,ll R){ return Get(R) - Get(L - 1); } ll Find(vector<ll> &v,ll x){ return *lower_bound(v.begin(),v.end(),x); } ll count_swaps(vector<ll> v){ ll n = v.size(),ans = 0; for (ll i = 0;i < n;i++){ ll now = v[i]; if (now > 0) pos[now].push_back(i); else neg[-now].push_back(i); } for (ll i = 0;i < n;i++){ if (was[i]) continue; ll now = v[i],nxt; if (now < 0){ nxt = Find(pos[-now],i); ans += nxt - i - Query(i,nxt) - 1; } else{ nxt = Find(neg[now],i); ans += nxt - i - Query(i,nxt); } was[nxt] = 1; upd(nxt,1); } return ans; } /* vector<ll> v; ll n,x; int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "test" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); } cin>>n; for (ll i = 1;i <= n;i++) cin>>x,v.push_back(x); cout<<count_swaps(v); } */

Compilation message (stderr)

shoes.cpp:1: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    1 | #pragma GCC optimization "Ofast"
      | 
shoes.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
/tmp/cct8EBz4.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status