Submission #670549

#TimeUsernameProblemLanguageResultExecution timeMemory
670549birthdaycakeArranging Shoes (IOI19_shoes)C++17
10 / 100
27 ms3528 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; long long vs[1001]; long long count_swaps(vector<int>s) { long long n = s.size(); long long ans = 0; for(long long i = 0; i < n; i++){ long long f = 0; for(long long j = 0; j < i; j++){ if(!vs[j] && s[i] == -s[j]){ f = j + 1; break; } } if(f){ f--; vs[f] = vs[f + 1] = 1; while(i != f + 1){ swap(s[i], s[i - 1]); i--; ans++; } if(s[f] > 0) { swap(s[f], s[f + 1]); ans++; } } } 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...