Submission #244421

#TimeUsernameProblemLanguageResultExecution timeMemory
244421tictaccatArranging Shoes (IOI19_shoes)C++14
10 / 100
5 ms384 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size() / 2; vector<vector<int>> posL(n+1), posR(n+1); for (int i = 0; i < 2*n; i++) { if (s[i] > 0) posR[s[i]].push_back(i); else posL[-s[i]].push_back(i); } int ans = 0; for (int j = 1; j <= n; j++) { for (int k = 0; k < (int)posR[j].size(); k++) { // cout << posL[j][k] << " " << posR[j][k] << "\n"; ans += abs(posR[j][k] - posL[j][k]) - 1; if (posL[j][k] > posR[j][k]) 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...