제출 #297907

#제출 시각아이디문제언어결과실행 시간메모리
297907erd1Arranging Shoes (IOI19_shoes)C++14
85 / 100
1091 ms34716 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() typedef int64_t lld; typedef pair<int, int> pii; #include<bits/extc++.h> using namespace __gnu_pbds; template<typename T, typename comp = greater<T>> using OST = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>; template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> p){ return out << "(" << p.ff << ", " << p.ss << ")"; } map<int, int> cnt; map<pii, int> mp; OST<int> ost; long long count_swaps(vector<int> s) { lld ans = 0; int id = 0; for(auto i: s)if(mp[{-i, cnt[i]}])mp[{i, cnt[i]}] = mp[{-i, cnt[i]}], cnt[i]++; else mp[{i, cnt[i]++}] = ++id; cnt.clear(), id = 0; for(auto i: s)id = (i > 0?mp[{-i, cnt[i]++}]*2+1:mp[{i, cnt[i]++}]*2), ans += ost.order_of_key(id), ost.insert(id); return ans; }
#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...