제출 #1067867

#제출 시각아이디문제언어결과실행 시간메모리
1067867LittleOrangeArranging Shoes (IOI19_shoes)C++17
45 / 100
28 ms5148 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; using ll = long long; struct BIT{ ll n; vector<ll> a; BIT(ll N):n(N),a(N+1,0){} void add(ll i, ll v){ for(;i<=n;i+=i&-i) a[i] += v; } ll get(ll i){ ll x = 0; for(;i>0;i-=i&-i) x += a[i]; return x; } }; ll invc(const vector<ll>& v){ ll n = v.size(); BIT t(n); ll r = 0; for(ll i = 0;i<n;i++){ r += i-t.get(v[i]+1); t.add(v[i]+1,1); } return r; } long long count_swaps(std::vector<int> s) { ll n = s.size()/2; vector<ll> to(n*2); ll il = 0, ir = 1; for(ll i = 0;i<n*2;i++){ if (s[i]<0){ to[i] = il; il+=2; }else { to[i] = ir; ir+=2; } } return invc(to); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...