제출 #228028

#제출 시각아이디문제언어결과실행 시간메모리
228028computerboxArranging Shoes (IOI19_shoes)C++14
10 / 100
1094 ms3192 KiB
#include <bits/stdc++.h> #include <cstdio> #include <cassert> #include "shoes.h" #define ll long long using namespace std; long long count_swaps(vector<int>massiv) { ll n=(ll)massiv.size(); ll cnt=0; for(ll i=0;i<n-1;i++) { if(i>=0 && massiv[i]<0 && massiv[i+1]>0 && -massiv[i]==massiv[i+1])continue; if(i>0 && massiv[i]>0 && massiv[i-1]<0 && massiv[i]==-massiv[i-1])continue; ll pos=0; ll sig=0; for(ll j=i+1;j<n;j++) { if(massiv[i]>0) { if(abs(massiv[j])==massiv[i]) { cnt+=(j-i); pos=j; sig=1; break; } } else { if(abs(massiv[i])==massiv[j]) { cnt+=(j-i-1); pos=j; sig=2; break; } } } if(sig==1) { for(ll j=pos;j>i;j--)swap(massiv[j],massiv[j-1]); } else if(sig==2)for(ll j=pos;j>i+1;j--)swap(massiv[j],massiv[j-1]); } return cnt; }
#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...