Submission #282352

#TimeUsernameProblemLanguageResultExecution timeMemory
282352GREGOIRELCArranging Shoes (IOI19_shoes)C++14
50 / 100
1096 ms3328 KiB
#include "shoes.h" #include <cmath> #include <iostream> using namespace std; long long count_swaps(vector<int> s) { int N = (int)s.size(); long long result = 0; for(int curPos = 0; curPos < N; curPos += 2) { int valide = 0; for(int pot = curPos + 1; pot < N; pot++) { if(abs(s[pot]) == abs(s[curPos]) && s[pot] + s[curPos] == 0) { valide = pot; break; } } //cout << curPos << " " << valide << endl; for(int i = valide; i > curPos + 1; i--) { swap(s[i], s[i - 1]); result++; } if(s[curPos + 1] < 0) { swap(s[curPos + 1], s[curPos]); result++; } } return result; }
#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...