Submission #1019945

#TimeUsernameProblemLanguageResultExecution timeMemory
1019945nisanduuArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms348 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { vector<int> cr = s; long long ans = 0; long long n = cr.size(); long long i=0; while(i<n){ long long pos = 0; for(long long j=i+1;j<n;j++){ if(cr[j]*-1 == cr[i]){ pos=j; break; } } //cout<<pos<<endl; long long end = i; ans += (pos - i - 1); if(cr[i]<0){ end = i+1; }else{ ans++; } for(long long j=pos;j>=1;j--){ if(j-1 == end){ break; } swap(cr[j],cr[j-1]); } i+=2; } 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...