Submission #172176

#TimeUsernameProblemLanguageResultExecution timeMemory
172176dsjongArranging Shoes (IOI19_shoes)C++14
10 / 100
1080 ms3064 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int n=s.size(); int cnt=0; for(int i=0;i<n;i++){ //cout<<i<<endl; if(s[i]<0){ for(int j=0;j<n;j++){ if(s[j]+s[i]==0&&!(s[j]+s[j-1]==0&&j<i)){ int cur=j; if(cur==i+1) break; if(cur>i){ while(cur!=i+1){ swap(s[cur],s[cur-1]); //cout<<cur<<" "<<cur-1<<endl; cur--; cnt++; } } else{ while(cur!=i){ swap(s[cur],s[cur+1]); //cout<<cur<<" "<<cur+1<<endl; cur++; cnt++; } } break; } } } } 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...