Submission #659058

#TimeUsernameProblemLanguageResultExecution timeMemory
659058BananArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms300 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define double long double #define endl '\n' #define sz(a) (int)a.size() #define pb push_back #define fs first #define sc second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() long long count_swaps(vector<int> s) { ll n=sz(s); map<ll, queue<ll>> m; vector<bool> mark(n+5, 0); for(ll i=0;i<n;i++) { m[s[i]].push(i); } ll ans=0; for(ll i=0;i<n;i++) { if(!mark[i]) { if(s[i]<0) { ans+=(m[-s[i]].front()-i-1); mark[m[-s[i]].front()]=1; mark[i]=1; m[-s[i]].pop(); m[s[i]].pop(); } else { ans+=(m[-s[i]].front()-i); mark[m[-s[i]].front()]=1; mark[i]=1; m[-s[i]].pop(); m[s[i]].pop(); } } } 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...