Submission #165387

#TimeUsernameProblemLanguageResultExecution timeMemory
165387andreiomdArranging Shoes (IOI19_shoes)C++17
50 / 100
1082 ms3292 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps (vector < int > S) { int N = (int)S.size(); long long ans = 0; for(int i = 0; i < N; i += 2) { int pos = 0; for(int j = i + 1; j < N; ++j) if(S[j] == -S[i]) { pos = j; break; } ans += (pos - i - 1); for(int j = pos; j > i + 1; --j) swap(S[j], S[j - 1]); if(S[i] > 0) ++ans, swap(S[i], S[i + 1]); } 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...