Submission #144777

#TimeUsernameProblemLanguageResultExecution timeMemory
144777monus1042Arranging Shoes (IOI19_shoes)C++17
45 / 100
32 ms2012 KiB
#include "shoes.h"

long long count_swaps(std::vector<int> s) {
    if (s.size()<=16){
		long long counterTOT=0;
		for (unsigned int i=0; i<s.size(); i+=2){
			unsigned int j;
			j=i+1;
			while(s[j]!=s[i]*-1){
				++j;
			}
			while(i+1!=j){
				std::swap(s[j],s[j-1]);
				++counterTOT;
				--j;
			}
			if (s[j]<0) {std::swap(s[j],s[j-1]); ++counterTOT;}
		}
		return counterTOT;
	}else{
		long long x=s.size()/2;
		return x*(x-1)/2;
	}
}
#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...