Submission #227699

#TimeUsernameProblemLanguageResultExecution timeMemory
227699Romario8Arranging Shoes (IOI19_shoes)C++17
10 / 100
5 ms384 KiB
#include<bits/stdc++.h> #define ll long long #define rep(i,a,b) for(ll i=a;i<b;i++) #define rrep(i,a,b) for(ll i=a;i>=b;i--) #define pb push_back #define rl "\n" #define x first #define y second using namespace std; long long count_swaps(vector<int> s) { ll ans=0; ll n=s.size(); vector<vector<ll>> pr(2*n+1); rep(i,0,n) { pr[s[i]+n].pb(i); if(pr[-s[i]+n].size()!=0) { ans+=i-pr[-s[i]+n][0]; if(s[i]>0)ans--; pr[-s[i]+n].erase(pr[-s[i]+n].begin()); pr[s[i]+n].erase(pr[s[i]+n].begin()); } } 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...