제출 #560204

#제출 시각아이디문제언어결과실행 시간메모리
560204jk410Arranging Shoes (IOI19_shoes)C++17
50 / 100
1095 ms72140 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; typedef long long ll; int N; int S[200001],Idx[200001]; bool Used[200001]; queue<int> A[100001]; 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].empty()&&S[A[x].front()]+S[i]==0){ Idx[A[x].front()]=i; A[x].pop(); } else A[x].push(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...