Submission #1004038

#TimeUsernameProblemLanguageResultExecution timeMemory
1004038LuvidiArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms348 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fs first #define sc second #define pb push_back long long count_swaps(std::vector<int> s) { int n=s.size()/2; vector<int> idx[2*n+1]; ll ans=0; for(int i=0;i<2*n;i++){ if(idx[n-s[i]].empty())idx[n+s[i]].pb(i); else{ int j=idx[n-s[i]].back(); idx[n-s[i]].pop_back(); ans+=(ll)(i-j-1); if(s[i]<0)ans++; } } 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...