Submission #560182

#TimeUsernameProblemLanguageResultExecution timeMemory
560182jk410Arranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms312 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; typedef long long ll; int N; int S[200001],A[200001],Idx[200001]; bool Used[200001]; int my_abs(int x){ if (x<0) return -x; return x; } ll count_swaps(vector<int> s){ ll ans=0; N=(int)s.size(); for (int i=1; i<=N; i++) S[i]=s[i-1]; for (int i=1; i<=N; i++){ int x=my_abs(S[i]); if (A[x]){ Idx[A[x]]=i; A[x]=0; } else A[x]=i; } for (int i=1; i<=N; i++){ if (Used[i]) continue; for (int j=i+1; j<Idx[i]; j++) ans+=(!Used[j]); if (S[i]>S[Idx[i]]) ans++; Used[i]=Used[Idx[i]]=true; } 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...